So, i’m work with C and OpenCobol, and, I whant to know if have an way to get the value of a internal cobol source…
for example (based on sample of this link):
http://www.opencobol.org/modules/bwiki/index.php?cmd=read&page=UserManual%2F2_3
---- say.cob ---------------------------
IDENTIFICATION DIVISION.
PROGRAM-ID. say.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 TESTE PIC 9(9) VALUE ZEROS.
LINKAGE SECTION.
01 HELLO PIC X(6).
01 WORLD PIC X(6).
PROCEDURE DIVISION USING HELLO WORLD.
MOVE 456 TO TESTE.
DISPLAY TESTE.
DISPLAY HELLO WORLD.
*> RETURN TESTE. ??????
EXIT PROGRAM.
----------------------------------------
And, the C code when I use is that:
—- hello.c —————————
#include <stdio.h>
#include <libcob.h>
extern int say(char *hello, char *world);
int
main()
{
int ret;
char hello[6] = "Hello ";
char world[6] = "World!";
cob_init(0, NULL);
ret = say(hello, world); // return the 000000456 ??????????
// How to make this :(
return ret;
}
----------------------------------------
Or, have an whay to get the cobol variable, something like this:
// ... code ...
int value = cob_getvar(TESTE);
// ... code ...
Look at page 7-7 of the OpenCOBOL Programmers Guide. For the data that you want to pass back to your C program, add another argument and pass it by reference to the COBOL program. Declare your
TESTEas binary to match the C declaration. You can also pass back the automatically-definedRETURN-CODE, if you like. So your COBOL would be something like this:And in your calling program: