It is possible in EASI to define a function that takes a variable number of arguments. This is accomplished by using the VARARGS keyword in the function definition's argument list, and the intrinsic function of the same name within the body of the function to access the additional arguments. The VARARGS keyword always appears at the end of the functions argument list, after any number fixed arguments (possibly none). For example, a function which takes a minimum of two arguments, followed by any number of additional arguments can be defined using a definition that starts with:
define function v( a, b, varargs ) ...
Once defined, the function can be called with two or more arguments. Within the body of a function that uses VARARGS, the number of additional arguments can be determined using the F$LEN intrinsic, and each of the arguments can be extracted by calling the intrinsic function VarArgs() with the number of the argument to extract.
The following is a variable argument version of the Max() function presented earlier:
define function vmax( arg1, arg2, varargs )
local double MaximumValue
local integer i
MaximumValue = arg1
if( arg2 > MaximumValue )then
MaximumValue = arg2
endif
for i = 1 to f$len(varargs)
if( varargs(i) > MaximumValue )then
MaximumValue = varargs(i)
endif
endfor
return( MaximumValue )
enddefine
The vmax() function must be called with at least two, and an arbitrarily large number of arguments.
© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.