Retrieving and storing pointers

In some cases (especially for shared library routines), you might have to obtain a pointer to the memory region associated with a MEMPTR variable. You might need this value, for example, to build a structure that contains a pointer to another structure. You can get a pointer to a MEMPTR region by using the GET-POINTER-VALUE function. This is the syntax for the GET-POINTER-VALUE function:

Syntax

GET-POINTER-VALUE ( memptr-name )

For example, to retrieve the pointer to a memory region specified by a MEMPTR variable (BitMapInfo) and store it in the first byte position of another MEMPTR variable (BitMaps), you can use the following statement (assuming 32-bit pointers):

PUT-LONG(BitMaps,1) = GET-POINTER-VALUE(BitMapInfo).

You can also store the address of a memory item into a MEMPTR variable by using the SET-POINTER-VALUE statement. Here is the syntax:

Syntax

SET-POINTER-VALUE ( memptr-name ) = address

For example, to store an address located at the second byte of a MEMPTR variable (BitMaps) into another MEMPTR variable (BitMapInfo), you can use the following statement:

SET-POINTER-VALUE(BitMapInfo) = GET-LONG(BitMaps,2)

For more information on the GET-POINTER-VALUE function and the SET-POINTER-VALUE statement, see ABL Reference.