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(opt1 { : opt2 { : opt3 { : opt4 { : opt5 }
} } })
Where opt1 ... opt5 can be *NOPASS, *OMIT, *VARSIZE, *STRING,
*TRIM, or *RIGHTADJ. 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.
- *OMIT
- The special value *OMIT may be passed for this reference parameter.
- *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.
- *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.
- *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) specified, the value will be trimmed
even if a pointer is passed directly. The null-terminated string that
the pointer is pointing to will be copied into a temporary, trimmed
of blanks, with a new null-terminator added at the end, and the address
of that temporary will be passed.
- *RIGHTADJ
- For a CONST or VALUE parameter, *RIGHTADJ indicates that the
graphic, UCS-2, or character parameter value is to be right adjusted.
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.