IBM AS/400 User Manual
For information on the data types supported by different HLLs, consult the appro-
priate language manual.
priate language manual.
Table 11. RPG Parameter Passing Methods
Passing By Reference
ILE RPG – prototype
D
proc
PR
D
parm
1A
C
CALLP
proc(fld)
ILE C
void proc(char *parm);
proc(&fld);
proc(&fld);
ILE COBOL
CALL PROCEDURE "PROC" USING BY REFERENCE PARM
RPG – non-prototyped
C
CALL
'PROC'
C
PARM
FLD
ILE CL
CALL PROC (&FLD)
Passing By Value
ILE RPG – prototype
D
proc
PR
D
parm
1A
VALUE
C
CALLP
proc('a')
ILE C
void proc(char parm);
proc('a');
proc('a');
ILE COBOL
CALL PROCEDURE "PROC" USING BY VALUE PARM
RPG – non-prototyped
N/A
ILE CL
N/A
Passing By Read-Only Reference
ILE RPG – prototype
D
proc
PR
D
parm
1A
CONST
C
CALLP
proc(fld)
ILE C
void proc(const char *parm);
proc(&fld);
proc(&fld);
ILE COBOL
N/A
1
RPG – non-prototyped
N/A
ILE CL
N/A
Notes:
1. Do not confuse passing by read-only reference with COBOL's passing BY
CONTENT. In RPG terms, to pass Fld1 by content, you would code:
C
PARM
Fld1
TEMP
Fld1 is protected from being changed, but TEMP is not. There is no expectation that
the parameter will not be changed.
the parameter will not be changed.
|
Interlanguage Calling Considerations
|
1. When returning a 1-byte character value to or from ILE C or ILE CL, the
|
returned value must be declared in a special way.
|
For ILE CL, declare the returned value as a 2-byte character and then use
|
%SUBSTRING to obtain the actual returned value.
|
DCL &RET2 TYPE(*CHAR) LEN(2)
|
DCL &RET1 TYPE(*CHAR) LEN(1)
|
CALLPRC RPGPROC RTNVAL(&RET2)
|
CHGVAR &RET1 VALUE(%SUBSTRING(&RET2 1 1))
Chapter 10. Calling Programs and Procedures
147