Jevgeni, if I understand you correctly, you want to retrieve a return code
value returned by a C program, inside a CL program.
One way I know how to do that is by calling the QUSRJOBI API with format
Here is sample CL source that calls my C program (ELVIS/RTNCDE), retrieves
the return code and then displays it to the end-user's screen.
NOTE: I used an &input argument to a C program just for illustration of
what's possible in CL, it's not required.
An easier way to accomplish this would be to make C's arguments into output
arguments. Then you can have a C program alter one or all of the output
arguments and CL can easily examine them since the storage is allocated in
the CL program itself. That option of course assumes you have access to
both C and CL source members.
That said, there are many other, better ways to have C and CL interoperate.
I strongly recommend you get up to snuff on ILE and CALLPRC. That way you
can create a single program from CL and C modules (and RPG, COBOL etc.) and
they can call each other's functions (procedures) and pass values back and
forth quite easily.
Celebrating 11-Years of SQL Performance Excellence on IBM i, i5/OS and
Subject: [C400-L] Returning parameters from C to CL
Reading AS/400 manuals makes me sick.
Tried to understand how to return value from a C program to a CL.
That is CL program calls C program and C program wants to return value to
Actually C program is mine, so whatever value can be returned - string or
It must be treated by CL as boolean - YES or NO.
If I call C program with a one parameter variable from CL and then modify
this parameter in C, then the changed value will be available in CL on
But is there a way to receive the return() value?
That is if I complete my C program with return(172), then CL somehow knows,
that 172 is returned?
Below is an extract from the manual (ILE/C programming guide, v.4,
p.265-266), it should be the thing I'm looking for
The following example shows how to retrieve a return value from main(). A CL
command called SQUARE calls an ILE C program SQITF. The program SQITF calls
another ILE C program called SQ. The program SQ returns a value to program
Note: Returning an integer value from an ILE C program may affect
1. To create a CL command prompt SQUARE usng the source shown below, type:
CRTCMD CMD(MYLIB/SQUARE) PGM(MYLIB/SQITF) SRCFILE(MYLIB/QCMDSRC)
You use the CL command prompt SQUARE to enter the item name, price, and
quantity for the ILE C program SQITF.
But I cannot understand, where the command SQUARE calls C program SQIFT and
HOW it reads returned value.
Sorry for my english, its not native. May be that's the problem :-(
This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact