|
STRUCT?
May 11, 2021 17:35:15 GMT -5
Post by Walt Decker on May 11, 2021 17:35:15 GMT -5
Given:
STRUCT tPtr, _ A$ AS PTR
B$ = "this is a test" tPtr.A$.struct = B$
PRINT tPtr.A$.struct
to what is tPtr.A$.struct pointing?
|
|
|
STRUCT?
May 11, 2021 19:27:22 GMT -5
Post by Carl Gundel on May 11, 2021 19:27:22 GMT -5
Given:
STRUCT tPtr, _ A$ AS PTR
B$ = "this is a test" tPtr.A$.struct = B$
PRINT tPtr.A$.struct
to what is tPtr.A$.struct pointing? At that moment it is pointing to the string in B$, but when you use the struct in a CALLDLL the struct will be copied into non BASIC memory along with the contents of B$. Then when the call returns the copying happens in reverse. This sort of thing is pretty common in high level languages that have external function interfaces to C style APIs.
|
|
|
STRUCT?
Jul 15, 2021 12:53:53 GMT -5
Post by Walt Decker on Jul 15, 2021 12:53:53 GMT -5
How does one embed structures?
Example:
STRUCT tPnt, _ X AS LONG, _ Y AS LONG
STRUCT tagMSG, _ hwnd AS ULONG, _ message AS ULONG, _ wParam AS ULONG, _ lParam AS LONG, _ time AS ULONG, _ Pnt AS tPnt.struct '<--- STRUCT tPnt here
|
|
|
STRUCT?
Jul 15, 2021 13:10:46 GMT -5
Post by Chris Iverson on Jul 15, 2021 13:10:46 GMT -5
I don't think you can in LB.
If it's a static embed, where all the contents of the struct are embedded in the parent struct(for example, the RECT structures in the COMBOBOXINFO structure), then you can just list the individual members of the sub struct in the parent struct.
Your example would look something like this:
STRUCT tagMSG, _ hwnd AS ULONG, _ message AS ULONG, _ wParam AS ULONG, _ lParam AS LONG, _ time AS ULONG, _ tPntX AS LONG, _ tPntY AS LONG
If you need to embed a pointer to a struct, you have no choice but to embed a ULONG into the spot to get the memory address, and then use RtlMoveMemory() to copy the data from the pointer into the LB struct.
|
|
|
STRUCT?
Jul 15, 2021 13:35:01 GMT -5
Post by Walt Decker on Jul 15, 2021 13:35:01 GMT -5
I don't think you can in LB.
That is what I thought by the # of syntax error I received when attempting different configurations.
I hope Mr. Gundle changes that in LB5.
|
|
|
STRUCT?
Jul 15, 2021 14:53:03 GMT -5
Post by Brandon Parker on Jul 15, 2021 14:53:03 GMT -5
Walt, If you really need this functionality, my Import Architect provides this type of functionality fairly easily. Feel free to check it out, and post on its forum if you like.
{:0)
Brandon Parker
|
|
|
STRUCT?
Jul 15, 2021 15:31:17 GMT -5
Post by Walt Decker on Jul 15, 2021 15:31:17 GMT -5
Thank you, Mr. Parker.
At the moment I do not need it, but I am sure I will need it when I get to playing around with graphics.
|
|