JavaScript Editor js editor     Web development 



Main Page

Returns the number of parameters passed to the most recently called program, procedure, or user-defined function.

PARAMETERS(В )

Return Value

Numeric

Remarks

PARAMETERS(В ) is useful for determining how many parameters are passed to a program, procedure, or user-defined function.

Note:
The value returned by PARAMETERS() is reset every time a program, procedure, or user-defined function is called or when ON KEY LABEL is executed. Unlike PARAMETERS(), the PCOUNT() function does not get reset, so PCOUNT() may be preferable in most programming situations.

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.

В Copy Code
* Example 1
DO testpar WITH 1,2,3

PROCEDURE testpar
PARAMETERS gn1,gn2,gn3
gcMessage = 'PARAMETERS( ) ='+ALLTRIM(STR(PARAMETERS( )))
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 PARAMETERS( ) 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 PARAMETERS( ) = 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



JavaScript Editor js editor     Web development