Description
VarArgs() is used in combination with the VarArgs keyword.
Call Signature
any_type VarArgs ( int index )
Return Value
any_type
The argument value. See Remarks.
Argument
int index:
The number of the additional argument to be fetched.
Remarks
This itrinsic function is used in combination with the VarArgs keyword in the argument list of the DEFINE FUNCTION statement which indicates that a function can take any number of additional arguments. When provided with an index argument, the VarArgs() intrinsic function fetches the value of the indicated additional argument. The number of additional arguments passed to the function can be computed by taking the f$len(varargs).
Example
The following is an example of a function named vmax() that takes two or more arguments and computes the maximum. The first two arguments to the function (arg1 and arg2) are explicitly listed to ensure that less than two arguments will be reported as a syntax error automatically. By including the keyword varargs as the last argument of the define function command, the system recognizes that the function may taken any number of additional arguments.
In order to determine how many additional arguments were passed, the f$len() function is invoked on the varargs keyword. This may be zero. Then the varargs() intrinsic function is used to get each of the extra arguments.
define function vmax( arg1, arg2, varargs )
local double max_value, int i
max_value = arg1
if( arg2 > max_value )then
max_value = arg2
endif
for i = 1 to f$len(varargs)
if( varargs(i) > max_value )then
max_value = varargs(i)
endif
endfor
return( max_value )
enddefine
© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.