Sets a variable of type MEMPTR to the value of a particular memory location.

Note: Does not apply to SpeedScript programming.

Syntax

SET-POINTER-VALUE ( memptr-var ) = memptr-value
memptr-var
A reference to a variable defined as MEMPTR.
memptr-value
An integer that represents a memory location.

Example

The following example calls a DLL routine that returns a pointer to a structure, extracts an address at byte 5 of the structure, uses SET-POINTER-VALUE to assign the address to an ABL MEMPTR, and displays the character string at the address:

DEFINE VARIABLE person_struct AS MEMPTR NO-UNDO. /* pointer to structure */
DEFINE VARIABLE name          AS MEMPTR NO-UNDO. /* pointer to name */

SET-SIZE(person_struct) = 8.

RUN person_info (OUTPUT person_struct).
SET-POINTER-VALUE(name) = GET-LONG(person_struct,5).
DISPLAY GET-STRING(name,1) FORMAT "x(50)".
SET-SIZE(person_struct) = 0.

PROCEDURE person_info EXTERNAL "person.dll" PERSISTENT:
  DEFINE OUTPUT PARAMETER person_struct AS MEMPTR.
END PROCEDURE.
CAUTION: In the example above, SET-POINTER-VALUE assigns MEMPTR name to a location within the memory allocated for person_struct. This is a common case where the memory pointed to by SET-POINTER-VALUE was not directly allocated by the shared library. Do not call SET-SIZE(memptr-var) = 0 on such a MEMPTR. The AVM will attempt to free that memory, which causes memory corruption and AVM instability. Instead, reset the pointer with SET-POINTER-VALUE(memptr-var) = ? when you are done with it.

Notes

  • SET-POINTER-VALUE is particularly useful when accessing Windows Dynamic Link Library (DLLs) or UNIX shared library routines from ABL. For more information on DLLs, see the topics on DLLs in OpenEdge Programming Interfaces.
  • For more information on the MEMPTR data type, see OpenEdge Programming Interfaces.

See also

GET-POINTER-VALUE function, SET-SIZE statement