I am learning COBOL just for the fun of it and now want to call C functions from my COBOL source (using GnuCOBOL).
I can call C functions just fine, however I have a small problem with a function of mine that looks like this: (It just wraps another function with the same arguments, for now)
int getSensors( char * protocol, int protocolLen,
char * model, int modelLen,
int * id, int * dataTypes ) {
return tdSensor(protocol, protocolLen, model, modelLen, id, dataTypes );
}
My problem is that the value that is returned in the id variable is not printable later in COBOL (TSI-ID below). For example the value returned can be 67, and if I print the variable in COBOL I get the ascii character 'C' instead of the expected value 0067.
The COBOL record looks like this:
01 TELLSTICK-SENSOR-ITER.
05 TSI-PROTOCOL PIC X(50).
05 TSI-MODEL PIC X(50).
05 TSI-ID PIC 9(4).
05 TSI-DATATYPES PIC 9(4).
05 TSI-RETURN PIC S9(4).
And my call looks like this:
CALL "getSensors" USING
BY REFERENCE TSI-PROTOCOL BY VALUE 50
BY REFERENCE TSI-MODEL BY VALUE 50
BY REFERENCE TSI-ID
BY REFERENCE TSI-DATATYPES
RETURNING TSI-RETURN.
I'm new to COBOL and my C skills are quite rusty as I usually work in Java. Is there an obvious newbie error in my code here?
INTERNET OF THINGS DIVISION
. – Wilhelminawilhelmine