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.

DLL Talk / How Pass an Array to plugin?

Author
Message
MadBit
Valued Member
10
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 1st Nov 2011 21:13
Hi,
i have two questions.
First How can I pass an array to a function of a plugin that written by me?
Example:


Second If it possible to make a new datatype with a plugin?
Example:


With Computers you can solve Problems that you have never befor.
Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
WLGfx
11
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 2nd Nov 2011 01:18
I'm hoping to find this out as well... I do know that Matrix1 Utils can retrieve the pointer to an array but then it has something like a 50 byte header...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
basjak
9
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 2nd Nov 2011 03:19
you have to use array pointer.

DBpro array format use the first 55 bytes to describe the comming array then followed by data.

in c++, array name is a pointer of the array's first element.

so, if you have an array, lets say a(10)

IanM
Retired Moderator
17
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Nov 2011 15:26
Quote: "I'm hoping to find this out as well"

You already have the code for it from the Interface library I uploaded - it's in the header file 'Support\Arrays.hpp'.

And for a simple example of how to use it, directly from my array plug-in:


The resource string for that command is:


You use 'H' as the input array type, but can't use it as a return type.

Accessing data is done using the DWORD* you receive into your code - Array[0] is the first pointer in the array and points to the actual data in memory. The format of the data pointed to depends on your array type, and for UDTs, on it's offset within that pointed-to data.

MadBit
Valued Member
10
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 2nd Nov 2011 20:46
@IanM:
Thank you for your answer. This will help me. And many thanks for sharing your brilliant library.

How does the access to TYPE's. is it the same way? and the access to individual elements in TYPE?

... and what is with my second question?
Quote: "Second If it possible to make a new datatype with a plugin?
Example:

"


With Computers you can solve Problems that you have never befor.
Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
IanM
Retired Moderator
17
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Nov 2011 21:45
No, no new datatypes.

First, non-UDT arrays just have a type value of 0 to 8 (ignore the bracketed letters at this point):
0 (L) = Integer
1 (F) = Float
2 (S) = String
3 (B) = Boolean
4 (Y) = Byte
5 (W) = Word
6 (D) = Dword
7 (O) = Double float
8 (R) = Double integer

If you do have a UDT array, then you have some work to do.

Accessing fields within a UDT requires you to work out offsets to add to the pointer you get and to access the data at that point appropriately.

You can get the UDT format using the GetTypePattern function from the Core plug-in (which is also defined for you in my interface library). Just pass a null pointer as the first argument, and the type of the array ( DBPro::Array::Type(ArrayPtr) ) as the second argument, and you will receive a string pointer in return - this contains the type pattern of the UDT.



The string contains the letters that represent the types (now go back an look at those bracketed letters I told you to ignore). All types increase the offset by 4 except for double integer (R) and double float (O). Booleans should be accessed as an unsigned char, as should Byte.

The offset of field 1 is zero, the offset of field 2 is the size of field 1, the offset of field 3 is the size of fields 1 & 2 etc.

Login to post a reply

Server time is: 2019-10-18 21:49:56
Your offset time is: 2019-10-18 21:49:56