IBM AS/400 Frozen Dessert Maker User Manual


 
Using a Prototyped Call
To call a prototyped program or procedure follow these general steps:
1. Include the prototype of the program or procedure to be called in the definition
specifications.
2. Enter the prototype name of the program or procedure in the extended Factor-2
field, followed by the parameters if any, within parentheses. Separate the
parameters with a colon (:). Factor 1 must be blank.
The following example shows a call to a procedure Switch, which changes the state
of the indicator that is passed to it, in this case *IN10..
C CALLP Switch(*in10)
A maximum of 255 parameters are allowed on a program call, and a maximum of
399 for a procedure call.
You can use CALLP from anywhere within the module. If the keyword EXTPGM is
specified on the prototype, the call will be a dynamic external call; otherwise it will
be a bound procedure call.
Note that if CALLP is used to call a procedure which returns a value, that value will
not be available to the caller. If the value is required, call the prototyped procedure
within an expression.
Calling within an Expression
If a prototyped procedure is defined to return a value then you must call the proce-
dure within an expression if you want to make use of the return value. Use the
procedure name in a manner that is consistent with the data type of the specified
return value. For example, if a procedure is defined to return a numeric, then the
call to the procedure within an expression must be where a numeric would be
expected.
Figure 61 shows the prototype for a procedure CVTCHR that takes a numeric input
parameter and returns a character string. Figure 62 shows how the procedure
might be used in an expression.
* Prototype for CVTCHR
* - returns a character representation of the numeric parameter
* Examples: CVTCHR(5) returns '5 '
* CVTCHR(15-124) returns '-109 '
D CVTCHR PR 31A
D NUM 30P 0 VALUE
Figure 61. Prototype for CVTCHR
C EVAL STRING = 'Address: ' +
C %TRIM(CVTCHR(StreetNum))
C + ' ' + StreetName
* If STREETNUM = 427 and STREETNAME = 'Mockingbird Lane', after the
* EVAL operation STRING = 'ADDRESS: 427 Mockingbird Lane'
Figure 62. Calling a Prototyped Procedure within an Expression
134 ILE RPG for AS/400 Programmer's Guide