User-defined functions

As introduced earlier, a function can be defined in EASI using the DEFINE keyword. A function is a unit of EASI code typically designed to accomplish a specific task. The body of a function can contain any EASI commands.

A function definition appears within an EASI script file, and an EASI script file may declare any number of functions. Once declared, a function is available for use by any other function or script regardless of which file the function was declared within.

A function definition includes specification of some number of arguments, which are values passed to the function when it is invoked. A function may optionally return a value using the RETURN command.

The syntax for a function definition is

DEFINE FUNCTION function_name ( arg1, arg2, ... )
 command_list
ENDDEFINE

where function_name is a unique name given to the function, following the same rules as variable names. That is, functions names must begin with a letter a-z, and followed by any number of letters, digits 0-9, and underscore characters "_".

arg1, arg2, ... argN are a list of argument names. There may be any number of arguments, or no arguments. It is also possible to specify a variable number of arguments.

command_list is the body of the function, comprised of any number of EASI commands.

The following is an example of a very simple function requiring no arguments, and which does not return any value. It can be used to temporarily halt the execution of a script.

define function WaitForUserResponse()
  local string InputValue
  input "Please press enter to continue: " InputValue
enddefine

The function prints a prompt to the screen using the INPUT command, and waits for the user to press the enter key. Any input the user types is stored in the local string variable InputValue, but since this value is not needed, it is never used. When execution reaches the end of a function definition, the function terminates, its local variables are lost, and control returns to where the function was invoked from; usually either another function or script, or the EASI command line.

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