%PARMS (Return Number of Parameters)
%PARMS returns the number of parameters that were passed to the procedure in which %PARMS is used. For a cycle-main procedure, %PARMS is the same as *PARMS in the program status data structure.
When %PARMS is used in a procedure that was called by a bound call, the value returned by %PARMS is not available if the calling program or procedure does not pass a minimal operational descriptor. The ILE RPG compiler always passes one, but other languages do not. So if the caller is written in another ILE language, it will need to pass an operational descriptor on the call. If the operational descriptor is not passed, the value returned by %PARMS cannot be trusted. The value returned by %PARMS will be -1 if the system can determine that the operational descriptor was not passed, but in some cases when the system cannot detect this, the value returned by %PARMS may be an incorrect value that is zero or greater.
The value returned by %PARMS includes the additional first parameter that is used to handle the the return value when the RTNPARM keyword is specified. For more information, see RTNPARM.
For more information, see Call Operations or Built-in Functions.
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++
*----------------------------------------------------------------
* MaxInt - return the maximum value of the passed parameters
*----------------------------------------------------------------
P MaxInt B
D MaxInt PI 10I 0
D p1 10I 0 VALUE
D p2 10I 0 VALUE
D p3 10I 0 VALUE OPTIONS(*NOPASS)
D p4 10I 0 VALUE OPTIONS(*NOPASS)
D p5 10I 0 VALUE OPTIONS(*NOPASS)
D Max S 10I 0 INZ(*LOVAL)
CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq..
CL0N01Factor1+++++++Opcode(E)+Extended-factor2+++++++++++++++++++++++++++
* Branch to the point in the calculations where we will never
* access unpassed parameters.
C SELECT
C WHEN %PARMS = 2
C GOTO PARMS2
C WHEN %PARMS = 3
C GOTO PARMS3
C WHEN %PARMS = 4
C GOTO PARMS4
C WHEN %PARMS = 5
C GOTO PARMS5
C ENDSL
* Determine the maximum value. Max was initialized to *LOVAL.
C PARMS5 TAG
C IF p5 > Max
C EVAL Max = p5
C ENDIF
*
C PARMS4 TAG
C IF p4 > Max
C EVAL Max = p4
C ENDIF
*
C PARMS3 TAG
C IF p3 > Max
C EVAL Max = p3
C ENDIF
*
C PARMS2 TAG
C IF p2 > Max
C EVAL Max = p2
C ENDIF
C IF p1 > Max
C EVAL Max = p1
C ENDIF
C RETURN Max
P MaxInt E