Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP - Matrix1Utils - Parsing Array Pointers (UDT) to functions - simple example1 on how to flag duplicate records and delete from array]

Bored of the Rings
User Banned
Posted: 12th Jul 2018 00:01 Edited at: 2nd Dec 2018 05:15
More fun with Array Pointers and Parsing them to functions. The example code below, reads in a DBO file (FPSC fully textured level) and stores each found texture file name into an array. The array is then sorted, and duplicates are flagged and finally deleted from the array. All by using array pointers. Tons I could do with this code to improve. I've used memblock here, but you can use banks or alloc/make memory.

The example is also good for anyone who wants to only load in a unique file for image ID storage, thus saving on resource/memory.

[update 1 17Jul18: I've excluded reading any blank strings by adding "AND pBLOCK <> 0"]

[update 2 17Jul18: Code updated to read in a DBO file containing a FPSC level with loads of textures (hint: DirectX texturefilename=). DBO file attached. In addition, added a new couple of useful functions at end of code. Hope this helps anyone wanting to do some more complicated stuff with string/array pointers/DBO to X conversion/exporting etc......]

[update 3 17Jul18: Another update, added a function to return field type as a long string e.g. S = String. It uses the get arrayptr field type(rlptr,f) command. Will be making the functions more generic.]

Notice also, that for each UDT field that you add, the array format gets longer and the offsets for each field goes up a DWORD in size i.e. 0,4,8,12 etc

[update 4 18Jul18: added undim arrayptr rlptr at end of code for completedness. Updated ShowArrayStatus function.. Saves array contents to file, so additional params added. now determines the field type and processes accordingly]

[update 30Jul18: updated FlagDups function to be more generic i.e. you have to specify the array fields Field1 needs to be a string and field2 needs to be either byte or boolean type. Validation checking of the input fields also added. Updated main code for call to FlagDups function and added some checking and end program if wrong types entered]

[update 31Jul18: updated an error in FlagDups Function code -> poke byte iptr2,fv TO poke byte iptr2,f2v ]
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others


Login to view attachments

Login to post a reply

Server time is: 2024-02-23 19:50:46
Your offset time is: 2024-02-23 19:50:46