Structure Handle
Structure Handle
How do you get the handle of a structure in PureBasic?
			
			
									
									
						- Kaeru Gaman
- Addict 
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
"Handle" is an unsusual term in PB since it's not OO. 
of course you can request handles of API objects,
but internal variables are accessed via pointers.
(like in C, not ++)
the pointer to a structure you'll get like every pointer to a variable:
note that the Name field is declared a string, but is also a long that holds the pointer to the string.
infinite strings within structs are stored as pointers.
for structs you want to pass to API-functions it's just the same,
use @Structname within the Call.
			
			
									
									of course you can request handles of API objects,
but internal variables are accessed via pointers.
(like in C, not ++)
the pointer to a structure you'll get like every pointer to a variable:
Code: Select all
Structure Customer
 Num.l
 Name.s
 Debid.l
EndStructure
Define Test.Customer
*pointer = @Test
Test\Num = 42
Test\Name = "George"
Test\Debid = 4711
Debug Test\Num 
Debug *pointer
Debug PeekL(*pointer)
*pointer + 4
Debug PeekL(*pointer)
*stringpointer = PeekL(*pointer)
Debug PeekS(*stringpointer)
*pointer + 4
Debug PeekL(*pointer)infinite strings within structs are stored as pointers.
for structs you want to pass to API-functions it's just the same,
use @Structname within the Call.
oh... and have a nice day.
						
