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.

Program Announcements / Array DLL - Updated

Author
Message
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 29th Jun 2003 22:29
I've just updated my array DLL with the following:

Sort ranges within a DBPro array
Clear ranges within a DBPro array
Swap 2 items within a DBPro array (can be faster than doing it yourself, and definitely easier)
Get a pointer to an array item.

The last one is a bit of an experiment on my part. You can now do this:



Let's see what you can make of it

Download it here : http://www.matrix1.demon.co.uk/DBPro/downloads/Matrix1Array_exe02.zip

or follow the link below to my site (not complete yet, but a darn sight better than it was).
Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 29th Jun 2003 22:41
how'd you get the pointer for the array to work?
and will you be making this in TPF format so we can call the functions normally?

I pride myself that i don't kill... well not without a good reason
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 29th Jun 2003 22:50
You can use the array pointer for various low-level array manipulations, but the commands I've included already do most of what you'd normally need to do. If you want the memory layout for arrays to do some of this stuff yourself, email me.

What's TPF? Do you mean TPC? Coz that's what it already is.
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 30th Jun 2003 01:21 Edited at: 30th Jun 2003 01:21
I'll probably use this for bits of BASS that usually require the passing of structures.

Is there any alignment details we should be aware of when passing from DBPro to C?

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 30th Jun 2003 01:40 Edited at: 30th Jun 2003 14:37
One other thing - have you called it Array.dll ?? I haven't downloaded it yet, y'see...

And strings - are they created in the usual way ?

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Jun 2003 15:07
Alignment details: I have no idea at the moment, but should be OK for a single array element. I don't know how DBPro packs its structures yet either. Once I have a set of working rules worked out, I'll post them.

strings: In a structure, they are stored as a pointer to the string data - matching LPSTR and LPCSTR

The DLL is called 'matrix1array.dll' - my standard naming convention to avoid clashes.
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 30th Jun 2003 15:27
I'll try it soon - still got the structure passed functions to do for BASS (3 lots of 3D vectors and various other bits).

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Jun 2003 20:33 Edited at: 30th Jun 2003 20:42
Well, it's simple for alignment and packing.

Structures are packed back to back in the initial allocation of an array, and the items within a structure are packed back to back, althought the initial structure seems to be correctly aligned.

Looks like we need to ensure that our structures are correctly formatted and aligned.

This structure is 9 bytes, while the equivalent in C/C++ would be 12 bytes:


(For those who don't know, the byte in the middle would be followed by 3 bytes of unused space to ensure that memory access is fastest - thats what is meant by packing. Alignment is similar - C/C++ use either 4 or 8 byte alignment/address is divisible by 4 or 8)

Oh well, it's better than nothing, even if it is a little inefficient to access unaligned memory.

Just change the code to this to fix it:
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 30th Jun 2003 20:36
Fair enough...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 2nd Jul 2003 21:39 Edited at: 2nd Jul 2003 21:44
Works very well - I'm testing it on the BASS structures at the moment...

Whilst ITEM PTR works, ARRAY PTR doesn't seem to point to the start of the array...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Jul 2003 23:56
That's right, it doesn't. If it was that easy, everyone would have worked out how arrays were organised by now

I left that function in for me to use. I have a DBPro function that when passed that pointer can print the contents of the array, no matter the value type being stored, except for UDT's of course - I have no way of working out how the structure is formatted from within code.

In fact, all of the commands in the DLL except for clearing an array can be written using only that pointer, except maybe not as efficiently
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 3rd Jul 2003 01:12
Ah fair enough - I'll let you off then! The ITEM PTR works well though...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!

Login to post a reply

Server time is: 2024-11-21 14:41:14
Your offset time is: 2024-11-21 14:41:14