A pointer is a number that points to a memory area.
thinBasic is a 32bit only process so under 32bit process, a pointer is 32bit so usually a DWORD but also a LONG is OK (internally the sign bit will not be interpreted as sign but will be part of the addressing)
Under a 64bit process, memory addressing pointer is represented by a QUAD (64 bit number)
What is allocated into a memory area and how it is interpreted is responsibility of the process and programmer.
The Operating system is just responsible of allocating/deallocating but how that memory are is interpreted is not a OS job.
The same memory area con be interpreted ad a number or a string or a type or whatever.
Just an example
USES "CONSOLE"
REM First, we declare variables a, b, and c
DIM a AS BYTE
DIM b AS BYTE
DIM c AS BYTE
REM Second, we assign a value to each variable
a = 1
b = 2
c = 3
REM Third, we print the address of each variable
printl "Defined 3 byte var: a, b, c, d"
printl "Values of a, b, c...........:", a,b,c
PRINTL "Varptr of a, b, c...........:", VARPTR(a), VARPTR(b), VARPTR(c)
PRINTL "Peek(Varptr) of a, b, c.....:", peek(byte, VARPTR(a)), peek(byte, VARPTR(b)), peek(byte, VARPTR(c))
printl "-----------------------------"
dim nLong as Long
nlong = 1234567898
printl "Defined 1 long var: nLong"
printl "Values nLong...............:", nLong
PRINTL "Varptr of nLong............:", VARPTR(nLong)
PRINTL "Peek(Varptr) of nLong......:", peek(long, VARPTR(nLong))
printl "-----------------------------"
dim bArray(4) as byte at varptr(nLong)
printl "Defined 1 array of 4 bytes at the memory location of nLong so the memory holding nLong can be interpreted in a different way"
printl "Values bArray(1)...............:", bArray(1)
printl "Values bArray(2)...............:", bArray(2)
printl "Values bArray(3)...............:", bArray(3)
printl "Values bArray(4)...............:", bArray(4)
PRINTL "Varptr bArray..................:", VARPTR(bArray(1)), "Should be the same as VARPTR(nLong) above"
WaitKey
Bookmarks