Pointer
See Also: Declaring Variables, Variable Declaration Commands, Struct, AddressOf Function
Purpose
Declares one or more Pointer variables.
Syntax
To declare Pointer variables:
Pointer {identifier} [… {identifier}]
Where:
- {identifier} is the name of a new Pointer variable.
- {identifier} may be between 1 and 4096 characters in length, must start with a letter, and may not contain spaces. Recommended characters are 0-9, a-z, A-Z, and _ (underscore).
To declare array variables of type Pointer:
Pointer {dimension-list} {identifier} [… {identifier}]
Where:
- {dimension-list} is a list of one or more array dimensions for the array. A dimension list is declared using square brackets
[]. One pair of brackets is used to declare each dimension. If the array is static, then you must specify the static size of each dimension between each pair of brackets, e.g.,[ {size} ]. For more information about declaring arrays, refer to Array Variable Assignments. - {identifier} may be between 1 and 4096 characters in length, must start with a letter, and may not contain spaces. Recommended characters are 0-9, a-z, A-Z, and _ (underscore).
What It Does
DataFlex Pointer types are used to declare variables for storing the memory address of a string variable.
Multiple variables may be declared on one command line, with their names separated from each other by spaces.
You can assign a value to a pointer variable with the AddressOf function. This command will retrieve the memory address of a named variable and return it to the pointer variable.
Examples
Procedure Test
Pointer lpComputerName
End_Procedure
This example declares a Pointer variable named lpComputerName.
Pointer[] lpDiskDriveInfo
This example declares one dynamic array variable named lpDiskDriveInfo, containing an undefined pointer of elements of type pointer.
Pointer[5] lpDiskDriveInfo
This example declares one static array variable named lpDiskDriveInfo, containing 5 elements of type pointer.
Pointer[][3] lpDiskDriveInfo
This example creates a two-dimensional dynamic array variable named lpDiskDriveInfo, containing an undefined pointer of elements of type pointer. Conceptually, this represents a rectangular array with an undefined number of rows, each containing 3 columns.
You can declare dynamic multi-dimensional arrays where all dimensions are dynamic; these are called jagged arrays.
Notes
- The Pointer type is primarily designed to be used when making DLL calls to the Windows API. It is used to store the address of Structure variables.
- If you need to define a global Pointer variable, you should use the global_variable command to do so.