IBM AS/400 manual Interlanguage, Calling Considerations

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 171
Image 171
Interlanguage

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);

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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');

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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);

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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

expe

the

parameter

will

not

 

be changed.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

For information on the data types supported by different HLLs, consul priate language manual.

Interlanguage

Calling Considerations

 

 

 

 

 

 

 

1. When returning a 1-byte character value to or

from ILE C or I

returned

value must

be

declared

in a

special

way.

For ILE CL, declare the returned value

as a 2-byte character a

%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

Procedures147

Page 171
Image 171
IBM AS/400 manual Interlanguage, Calling Considerations