PDA

View Full Version : "any" and "ptr" :)



Lionheart008
12-06-2009, 22:00
hi all :)

how can I find more about these thinbasic commands "any" and "ptr" ??? the help manual is silent..


'- testscript with "any" and "ptr" by lionheart :)

uses "console"

DECLARE SUB PrintFirstByte( x as any ptr ) '- ptr is not necessary ;)

dim i,k as integer
dim z,v as string * 48
dim s as string
i = -1
k = -100
s = "hello World!"
z = "hello brave new World!"
v = "nothing is impossible with thinbasic!"
printl
PrintFirstByte i
printl
Printl s
Printl z
Printl v
printl
PrintFirstByte k
printl
waitkey

SUB PrintFirstByte( x as any )
printl x
printl k
END SUB

found it also last night in a freebasic script and have translated and changed / improved it for thinbasic ;)

best regards, Lionheart

Charles Pegge
12-06-2009, 23:44
Hi Frank,

any is a sort of wild card - any data type id accepted whether it's a dword or double or a UDT.

ptr means the address of the variable is passed - not the contents of the variable.

qualifying a parameter as byval .. as any ptr is a way of bypassing type checking.

Charles