Try OpenEdge Now
skip to main content
Programming Interfaces
External Program Interfaces : Host Language Call Interface : Using HLC library functions : Accessing ABL data
 
Accessing ABL data
This section describes how to use HLC library functions to access ABL data. For example, you can use the prordbi() function to read an integer field in a shared buffer. Use the following guidelines when accessing ABL data with HLC library functions:
*Use correct data types for the parameters you pass to HLC library functions — In general, C compilers do not verify whether the data types of the parameters you provide in a function call agree with the parameter data type definitions specified in the function declaration.
*Use correct values for the parameters you pass to HLC library functions — For example, HLC functions that access ABL shared buffers use the fhandle parameter. The fhandle parameter has the INTEGER data type. You must set fhandle correctly to read from or write to the correct location in the buffer.
*Use pointer variables properly — Many HLC library functions that access ABL use pointer variable parameters. Improper use of pointer variables can cause you to overwrite random locations in memory, with potentially hazardous results.
Caution: If you do not follow these guidelines, you can permanently damage your OpenEdge database.
The following example demonstrates these guidelines by defining shared buffer custbuf within an ABL procedure:
DEFINE NEW SHARED BUFFER custbuf FOR Customer.

FIND FIRST custbuf.
CALL subfunc1.
Later in your ABL code, execute a CALL statement that calls a C function. Within the C function, you read the custnum field. The custnum field is an integer field in the customer table, for which shared buffer hlcbuff is defined. For example:
#include "hlc.h"
subfunc1()
{
int ret, index, unknown;
char message[80];
long cnum;
int fhandle;

index = 0;
unknown = 0;

fhandle = profldix ("custbuf", "custnum");
ret = prordbi ("custbuf", fhandle, index, &cnum, &unknown);
if (ret||unknown)
{
sprintf (message, "prordbi fatal ret = %d unknown %d", ret, unknown);
promsgd (message);
}
sprintf(message, "customer.custnum was %ld", cnum);
promsgd(message);
return 0;
}
The prordbi() function reads an integer field contained in a shared buffer. To determine the HLC library function to use, see the function summary in HLCLibrary Function Reference.
This is the syntax for the prordbi() function:

Syntax

int prordbi ( pbufnam , fhandle , index , pvar , punknown )
char *pbufname ;
int fhandle ;
int index ;
long *pvar ;
int *punknown ;
The pbufnam parameter points to the name of the specified shared buffer. You supply the name from your OpenEdge application.
The fhandle input parameter is the field handle that profldix() returns for the specified field.
The index input parameter specifies an index value for an array field. If the field is a scalar, you must set the value of index to 0.
The pvar output parameter points to a long where prordbi() returns the value of the specified integer field.
The punknown output parameter points to an integer where prordbi() returns 1 if the field has the Unknown value (?), and returns 0 otherwise.
The following figure shows a call being made to prordbi() that illustrates HLC programming guidelines.
Figure 66. Example HLC library function call