PCOUNT( ) Function
Returns the number of parameters passed to the current program, procedure, or user-defined function.
PCOUNT( )
Return Values
Numeric
Remarks
PCOUNT( ) is useful for determining how many parameters are passed to the current program, procedure, or user-defined function.
Examples
Example 1 calls a procedure and displays in a wait window the number of parameters passed.
Example 2 uses a procedure to display the average of 4 values.
Example 1
DO testpar WITH 1,2,3
PROCEDURE testpar
PARAMETERS gn1,gn2,gn3
gcMessage = 'PCOUNT( ) ='+ALLTRIM(STR(PCOUNT( )))
WAIT WINDOW (gcMessage)
RETURN
Example 2
SET TALK OFF
gnVal1 = 10
gnVal2 = 20
gnVal3 = 30
gnVal4 = 15
gnMin = getavg(gnVal1, gnVal2, gnVal3, gnVal4)
? 'Average value is '
?? gnMin
* This user-defined function permits up to 9 parameters to be passed.
* It uses the PCOUNT( ) function to determine how many
* were passed and returns the average value.
FUNCTION getavg
PARAMETERS gnPara1,gnPara2,gnPara3,gnPara4,gnPara5, ;
gnPara6,gnPara7,gnPara8,gnPara9
IF PCOUNT( ) = 0
RETURN 0
ENDIF
gnResult = 0
FOR gnCount = 1 to PARAMETERS( )
gcCompare = 'gnPara' +(STR(gnCount,1))
gnResult = gnResult + EVAL(gcCompare)
ENDFOR
gnResult = gnResult / (gnCount - 1)
RETURN gnResult
See Also
DO Command | FUNCTION Command | LPARAMETERS Command | LOCAL Command | PARAMETERS Command | PARAMETERS( ) Function | PRIVATE Command | PROCEDURE Command | PUBLIC Command | SET UDFPARMS Command