Skip to content

Num_Arguments (Variable Parameter Lists)

See Also: Function, Procedure

Purpose

To provide the number of arguments passed with each invocation of a procedure or function.

Type

Integer

What It Does

Num_Arguments carries the number of arguments passed to a function or procedure. It can be used only within a function or procedure. Its value can change with each invocation of the function or procedure.

Function Mean Global Integer i1 Integer i2 Integer i3 Returns Integer
    Integer iArgs
    Move Num_Arguments to iArgs
    If (iArgs = 3) Function_Return ((i1 + i2 + i3) / iArgs)
    Else If (iArgs = 2) Function_Return ((i1 + i2) / iArgs)
    Else If (iArgs = 1) Function_Return i1
    Else Function_Return 0
End_Function

In this example, the function Mean is defined using three parameters: integers i1, i2, and i3. The [Function_Return](Function_return_Command.md) statement contains an expression to calculate the mean of the values input. The function for calculating the return value uses Num_Arguments to provide a value appropriate to the number of arguments passed with each invocation.

Notes

  • Num_Arguments is a local variable. That is, it is local to each function or procedure. Therefore, a variable of that name might concurrently have different values in two or more functions or procedures.