Consultor Eletrônico



Kbase P6444: 4GL: How to access a pointer from a MEMPTR structure?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   4/16/2009
Status: Verified

GOAL:

4GL: How to access a particular pointer from a MEMPTR structure?

GOAL:

How to use a pointer to a C structure returned by a DLL or OCX

FACT(s) (Environment):

All Supported Operating Systems
Progress/OpenEdge Product Family

FIX:

Use the GET-LONG() function and SET-POINTER-VALUE() statement as illustrated bellow:
DEFINE VARIABLE person_struct AS MEMPTR. /* pointer to structure */
DEFINE VARIABLE name AS MEMPTR. /* pointer to name */
DEFINE VARIABLE Phone AS MEMPTR. /* pointer to Phone Number */
DEFINE VARIABLE Addr1 AS MEMPTR. /* pointer to Address 1 */

SET-SIZE(person_struct) = 16. /*4 reserved bytes + 3 * 4 Bytes */

PROCEDURE person_info EXTERNAL "person.dll" PERSISTENT:
DEFINE OUTPUT PARAMETER person_struct AS MEMPTR.
END PROCEDURE.

RUN person_info(OUTPUT person_struct).

SET-POINTER-VALUE(name) = GET-LONG(person_struct,5).
SET-POINTER-VALUE(phone) = GET-LONG(person_struct,9).
SET-POINTER-VALUE(addr1) = GET-LONG(person_struct,13).
DISPLAY
GET-STRING(name,1) FORMAT "x(50)"
GET-STRING(phone,1) FORMAT "x(50)"
GET-STRING(addr1,1) FORMAT "x(50)".