3.14 GOTO

Use GOTO to execute a portion of the login script out of the regular sequence.

Set BREAK ON in your login script before experimenting with GOTO loops so that you can break out of a login script if necessary. See Section 3.7, BREAK.

IMPORTANT:Do not use GOTO to enter or exit a nested IF...THEN statement. This usage causes problems for the program.

Command Format

GOTO label

Use label to indicate where the login script should continue executing.

In Windows, the label can take formats :label (colon before) or label: (colon after). When the colon comes before the label, any words may be used with the label. When the colon comes after, do not use words that also represent a command or they are interpreted as a command.

Example

To execute a loop of commands, include the following lines in the login script. In this case, the commands to be executed are labeled AGAIN (as indicated in the second line).

SET X="1"
AGAIN:
SET X=<X> + "1"
;see compound strings for this
WRITE <X>
IF <X> < "9" THEN GOTO AGAIN

The GOTO command looks at the value of <X> (a DOS environment variable). If the value of <X> is less than 9, then <X> increments by 1 and GOTO loops back to the AGAIN label. When <X> gains the value of 9, the IF...THEN test becomes false, the GOTO is ignored, and the script continues normally.