Kbase 22012: Example of the EPI Call Command with 'C' Program in AS/400
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  5/3/2002 |
|
SUMMARY:
The EPI call command allows the Progress 4GL to call programs written in languages supported by OS/400. The example in this Knowledge Base Solution demonstrates a *C* program that resides in the AS/400. The C program is called by the Progress 4GL Native Client with the EPI Call Command.
EXPLANATION:
A C program is able to take in parameters, and all parameters are passed in by the reference. This means that an address or pointer to a value in the 4GL program is passed to the C program. EPI passes by reference as well. It follows that if the memory at the address of one of the parameters is changed, the Progress program will be able to see those changes.
Here is a sample code:
define new shared variable word as character.
os400 epi call pgm(pgm1)
parm(word as char len(50)).
display word. /* In theory this should be HELP */
.
.
.
Simple source for pgm1
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv) {
memcpy(argv[1], "HELP", 4); /* assumes the buffer for argv[1] is
large enough */
return 0;
}
References to Written Documentation:
Progress/400 Product Guide Chapter 11, section 11.1 and 11.1.2.