Function

The DEFINE command can be used to define new EASI functions, which operate in a manner analogous to the pre-defined intrinsic functions. These functions take either fixed, including none, or arbitrary number of arguments. An arbitrary number of arguments is supported via VarArgs() intrinsic function. Functions may optionally return a value.

  DEF[INE] FUNCTION function_name ( [arg1[, arg2] ... ])
    command_list ...
  ENDDEFINE

Example:

 define function isprime( a )
   local max_div, i
   max_div = F$INT( a^0.5 + 1)
   for i = max_div ... 2 by -1
     if( (a/i) = F$INT(a/i) ) return( "FALSE" )
   endfor
   return( "TRUE" )
 enddefine

The arguments may be of any defined type. The invocation of a user defined function is, in many ways, analogous to invoking a new EASI procedure file. The function has a new variable scope, but may access global variables declared by calling levels. The advantage of user defined functions over separate procedure files is the ability to pass arguments and return values, simplifying encapsulation.

© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.