Ptr

From Xojo Documentation

Data Type


A reference to a chunk of memory. You can pass a MemoryBlock object via this data type and it will be treated as a pointer to the memory contained within the MemoryBlock.

Methods
Boolean Int32 UInt16
Byte Int64 UInt32
CFStringRef Int8 UInt64
CString Integer UInt8
Color Object UInteger
Currency Single Variant
Double String WString
Int16 Text

Notes

A Ptr is 4 bytes for 32-bit apps and 8 bytes for 64-bit apps.

You can compare one Ptr to another Ptr or to Nil.

You can convert the value referenced to by the pointer to a specific data type using the available methods.

You can convert the value referenced to by the pointer to a specific datatype using the Pointer Properties: Boolean, Byte, CFStringRef, Class, Color, CString, Currency, Double, Int16, Int32, Int64, Int8, Integer, Object, Ptr, Short, Single, String, UInt16, UInt32, UInt64, UInt8, Variant, WindowPtr, WString

Sample Code

Dim p1, p2, p3 As Ptr

p1 = AddressOf someMethod
p2 = someMemoryBlock // A Ptr to the MemoryBlock itself
p3 = someMemoryBlock.Ptr(n) // Retrieve Ptr stored within the MemoryBlock at offset n

Notes

You can compare one Ptr to another or to Nil.

See Also

AddressOf method; Declare statement; MemoryBlock class; MemoryBlock.Ptr function.