It is possible to transfer execution to any line within the same procedure by using the GOTO statement. The form of the statement is:
GOTO location
where
[location] is an existing line number between 1 and 9999, or a
statement label
Example 1:
GOTO 1500
Example 2:
IF (VALUE > 0) THEN GOTO 57 ENDIF
Example 3:
SMALL: \ print "This amount is insignificant." ! This next part comes later in the program IF (AMOUNT < 5) THEN GOTO SMALL ENDIF
The GOTO statement can redirect the path of your procedure in a host of new directions, freeing you from programming in a strictly linear fashion. You may have noticed that, until now, there has not been any discussion regarding the use of line numbers. EASI can accept a program that uses line numbers to identify command lines but line numbers are not necessary. Since EASI follows your instruction in a line-by-line fashion, lines of procedure are executed in order. This makes editing the structure of a procedure much less tedious. However, commands such as the GOTO command present special concerns since they clearly need some form of specific direction or address to complete their task. Using labels along with the GOTO command solves this problem.
A label is not so much a command as it is a beacon. Label formats are limited only to the following criteria:
Labels are not variables and label names are not declared at the beginning of a program with a LOCAL command.
When told to GOTO a specific label, the procedure will prompt the computer to look for a specific label within the instruction rather than a line number. An example that illustrates the use of a label would be:
local string yn print "This program demonstrates using labels with GOTO statements" ASKAGAIN: \ input "Do you wish to run this program? (Y/N): " yn if (yn <> "Y" and yn <> "N") then goto ASKAGAIN endif print "Thank You"
The label being used is ASKAGAIN. Without the input of a "Y" or an "N", the program will continue to loop back to the ASKAGAIN label. Once the requirements of the IF statement are met, the final PRINT statement will be executed.
Note that a "backslash" (\) follows the first ASKAGAIN statement. Recall that when the backslash is the last character on a line of text, the next line is considered to be part of the current line.
There are certain circumstances where GOTO's should not be used. GOTO's should not be used to exit TRY or MODEL statements (these statements are described in detail in later chapters).
© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.