Prototyped Parameters
Prototyped Parameters
If the prototyped call interface involves the passing of parameters then you must define the parameter immediately following the PR or PI specification. The following keywords, which apply to defining the type, are allowed on the parameter definition specifications:
ASCEND : The array is in ascending sequence.
DATFMT(fmt) : The date parameter has the format fmt.
DESCEND : The array is in descending sequence.
DIM(N) : The parameter is an array or data structure with N elements.
LIKE(name) : The parameter is defined like the item specified by the keyword.
LIKEREC(name{,type}) : The parameter is a data structure whose subfields are the same as the fields in the specified record format name.
LIKEDS(data_structure_name) : The parameter is a data structure whose subfields are the same as the subfields identified in the LIKEDS keyword.
LIKEFILE(filename) : The parameter is a file, either filename or a file related through the LIKEFILE keyword to filename.
PROCPTR : The parameter is a procedure pointer.
TIMFMT(fmt) : The time parameter has the format fmt.
VARYING{(2|4)} : A character, graphic, or UCS-2 parameter has a variable-length format.
For information on these keywords, see Definition-Specification Keywords.
The following keywords, which specify how the parameter should be passed, are also allowed on the parameter definition specifications:
CONST : The parameter is passed by read-only reference. A parameter defined with CONST must not be modified by the called program or procedure. This parameter-passing method allows you to pass literals and expressions.
NOOPT : The parameter will not be optimized in the called program or procedure.
OPTIONS(option1 { : option2 { : option3 { … } } }) : Where the options can be *NOPASS, *OMIT, *VARSIZE, *STRING, *TRIM, *RIGHTADJ, *NULLIND, *EXACT, or *CONVERT. For example, OPTIONS(*VARSIZE : *NOPASS).
Specifies the following parameter passing options:
\*NOPASS
: The parameter does not have to be passed. If a parameter has
OPTIONS(\*NOPASS) specified, then all parameters following it must
also have OPTIONS(\*NOPASS) specified.
See [OPTIONS(\*NOPASS)](/doc/en/docs/rpg-reference/doptns/#doptns__nopass).
\*OMIT
: The special value \*OMIT may be passed for this reference parameter.
See [OPTIONS(\*OMIT)](/doc/en/docs/rpg-reference/doptns/#doptns__omit)
\*VARSIZE
: The parameter may contain less data than is indicated on the
definition. This keyword is valid only for character parameters, graphic
parameters, UCS-2 parameters, or arrays passed by reference. The called
program or procedure must have some way of determining the length
of the passed parameter.
Note: When this keyword is omitted
for fixed-length fields, the parameter may only contain more or the
same amount of data as indicated on the definition; for variable-length
fields, the parameter must have the same declared maximum length as
indicated on the definition.
See [OPTIONS(\*VARSIZE)](/doc/en/docs/rpg-reference/doptns/#doptns__varsize)
\*STRING
: Pass a character value as a null-terminated string. This keyword
is valid only for basing pointer parameters passed by value or by
read-only reference.
See [OPTIONS(\*STRING)](/doc/en/docs/rpg-reference/doptns/#doptns__string)
\*TRIM
: The parameter is trimmed before it is passed. This option is
valid for character, UCS-2 or graphic parameters passed by value or
by read-only reference. It is also valid for pointer parameters that
have OPTIONS(\*STRING) coded.
Note: When a pointer parameter
has OPTIONS(\*STRING : \*TRIM) or OPTIONS(\*CONVERT : \*TRIM) specified, the value is trimmed
even if a pointer is passed directly. The null-terminated string that
the pointer is pointing to is copied into a temporary, trimmed
of blanks, with a new null-terminator added at the end, and the address
of that temporary is passed.
See [OPTIONS(\*TRIM)](/doc/en/docs/rpg-reference/doptns/#doptns__trim)
\*RIGHTADJ
: For a CONST or VALUE parameter, \*RIGHTADJ indicates that the
graphic, UCS-2, or character parameter value is to be right adjusted.
See [OPTIONS(\*RIGHTADJ)](/doc/en/docs/rpg-reference/doptns/#doptns__rightadj)
\*NULLIND
: When OPTIONS(\*NULLIND) is specified for a parameter, the null-byte
map is passed with the parameter, giving the called procedure direct access
to the null-byte map of the caller's parameter.
See [OPTIONS(\*NULLIND)](/doc/en/docs/rpg-reference/doptns/#doptns__nullind).
\*EXACT
: When OPTIONS(\*EXACT) is specified, the compiler is more strict about the parameters
that may be passed.
See [OPTIONS(\*EXACT)](/doc/en/docs/rpg-reference/doptns/#doptns__exact).
\*CONVERT
: When OPTIONS(\*CONVERT) is specified for a parameter,
the data type of the passed parameter can be different from the
data type of the prototyped parameter.
See [OPTIONS(\*CONVERT)](/doc/en/docs/rpg-reference/doptns/#doptns__convert).
Tip:
For the parameter passing options \*NOPASS, \*OMIT, and \*VARSIZE,
it is up to the programmer of the procedure to ensure that these options
are handled. For example, if OPTIONS(\*NOPASS) is coded and you choose **not** to pass the parameter, the procedure
must check that the parameter was passed before it accesses it. The
compiler will not do any checking for this.
VALUE : The parameter is passed by value.
For information on the keywords listed above, see Definition-Specification Keywords. For more information on using prototyped parameters, see the chapter on calling programs and procedures in the Rational® Development Studio for i: ILE RPG Programmer’s Guide.