Use the CALL statement
- Last Updated: August 23, 2021
- 2 minute read
- OpenEdge
- Version 12.2
- Documentation
Use the ABL CALL statement to execute
a C function from an ABL procedure.
This is the syntax for the CALL statement:
Syntax
|
The routine-identifier is the name the PRODSP() dispatch
routine maps to an actual C function. The routine identifier is case sensitive; it must have
the same letter case as its definition in the dispatch routine.
The argument is one or more arguments that you want to pass to the C function. Arguments passed to the C function must be read only. If you supply multiple arguments, separate them with spaces. If you separate them with other delimiters, such as commas, ABL passes the delimiters as arguments. ABL converts all arguments to C character strings before passing them to a C function; ABL passes them as an array of character pointers. Therefore, your C functions must expect null-terminated character strings and perform data conversions as necessary.
The following figure demonstrates how to run the CALL statement.

The following CALL statement executes hlcroutine, the
routine identifier for your C function:
|
When you use a CALL statement to invoke a routine that
updates a shared buffer, you must make sure that a transaction is
active at the time of the call. For more information, see Use a library function that writes to a shared buffer.
The CALL statement transfers control to the HLC dispatch routine,
PRODSP(), passing it your routine identifier and any arguments. The
example in the above figure passes the hlcroutine routine identifier with no arguments to
PRODSP(), which is located in hlprodsp.c.
You must modify the prototype hlprodsp.c file supplied with OpenEdge HLC to
define your routine identifiers and C function names. Based on definitions you have set up
in hlprodsp.c, the PRODSP() dispatch routine maps the
routine identifier to your C function, and calls it. The example in the above figure maps
hlcroutine to the function hlcfunc().
If the PRODSP() dispatch routine does not define the routine identifier or
defines it with a different letter case, an error results.