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 Int16 UInt16
Byte Int32 UInt32
CFStringRef Int64 UInt64
CString Int8 UInt8
Color Integer UInteger
Currency Single WString
Double Structure

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 assign a Ptr to a MemoryBlock.

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

Var 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.