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 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