Variable scopes

The scope of a variable is the region of code in which it is defined and can be used. There are two types of scopes in EASI: local and global. The particular scope in which a variable exists depends on the way in which it is declared. Local variables are declared with the LOCAL command, and global variables with the GLOBAL command.

Local variables exist only while the procedure in which they were declared is being executed, and may only be accessed within the procedure in which they were declared. Each procedure has its own distinct local scope. If a procedure is designed to access and run other procedures outside of its own programming, the locally declared variables of the initial procedure will remain declared while the second procedure runs, but will not be available to the second procedure. Once any procedure completes (returns), all its local variables are lost. The advantage of using local variables is that by declaring variables local the user is guaranteed that no other procedure has access to those variables.

Unlike local variables, global variables are available to any procedure after they are declared, and continue to exist until EASI itself terminates. In previous versions of EASI, a special statement called IMPORT was required in order for a global variable to be used within a procedure other than the one in which it was declared. However, the use of the IMPORT statement is no longer required, and global variables are automatically available to all procedures.

If both a local and global variable have the same name, then any references to that variable are considered by EASI to be references to the local version. Hence access to the global variable of the same name will no longer be possible.

For example, suppose a procedure declares two variables: variable A is declared to be global and variable B is declared to be local. The procedure is able to access and set both of these variables.

global integer a
local integer b
a = 1
b = 2

Suppose next that this procedure calls a second procedure, called Func2.

call Func2()

The new procedure Func2 will be able to access the global variable A since it was declared global, but will be unable to access the variable B since it was declared local to the other procedure.

a = 5

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