Skip to content

AddressOf

See Also: Memory Management Functions, LongPtr, ULongPtr, 64 bit Data Types

Purpose

The AddressOf function returns a pointer to an argument.

Return Type

Pointer

Syntax

AddressOf({var})

Where:

  • {var} can be any variable, but not an expression or a constant value.

Example

Procedure TestAddressOf
    Integer i iVal
    Pointer pAddressOfI

    Move 50 to i
    Showln "i = " (string(i)) // This will show i = 50

    Move (AddressOf(i)) to pAddressOfI
    // Store 100 in i using the pointer pAddressOfI
    Move (StoreDW(pAddressOfI, 0, 100)) to iVal

    Showln "i = " (string(i)) // Shows i = 100
End_Procedure

Important Notes

  • When obtaining a pointer to a local variable, you must first initialize the variable by assigning it a value. If you do not do this, the pointer returned will not be valid. In the above example, the "Move 50 to i" properly initialized the variable.

  • You cannot use AddressOf with a variable that has not been initialized to a value.

  • The Address data type is obsolete.