The @GOTO statement is used in @DO procedures to branch to a line. The line number is specified in the @GOTO statement. The line must exist and must not be located outside of the procedure.
If a @GOTO statement is specified in an @IF statement then a condition-dependent branch is possible in a @DO procedure. If the condition is fulfilled then processing branches to the line specified in the GOTO statement. If the condition is not fulfilled then the procedure continues with the statement which immediately follows the @IF statement.
To prevent the possible displacement of lines when the procedure is modified, the line numbers should be determined again with @SET, format 6 (abbreviated to @ for improved clarity) before branch destinations are specified (see also example).
Branches are not permitted in @INPUT procedures.
Example of unconditional and conditional branches
@PROC 2 @DELETE @1.00 ---------------------------------------------------------------- (01) @ @CONTINUE *** LINE NUMBER 1.00 AS OF HERE *** @ @CREATE #S1 READ 'PLEASE ENTER SEARCH TERM: ' ---------------------- (02) @ @ON & FIND #S1 MARK 5 @ @IF .TRUE. @GOTO 2 ------------------------------------------------- (03) @ @CREATE #S2: 'NO HIT FOUND' @ @PRINT #S2 @ @GOTO 3 ------------------------------------------------------------ (04) @2.00 @ @CONTINUE *** LINE NUMBER 2.00 AS OF HERE *** @ @DELETE MARK 5 @ @ON & PRINT #S1 ---------------------------------------------------- (05) @3.00 @ @CONTINUE *** LINE NUMBER 3.00 AS OF HERE *** @END
(01) | Statement @1.00 sets line number |
(02) | @CREATE...READ prompts the user to enter a search term. In the following line, all the lines which contain the search term are flagged with record mark |
(03) | @IF checks whether there are any hits and, if there are, branches to line |
(04) | If there are no hits, the corresponding message is output and processing branches to the end of the procedure. |
(05) | If there are hits, the record mark is deleted and the hit lines are output. |
The lines with two consecutive statement symbols are read back into the lines defined by the @ statement in work file 2
. The EDT procedure can then be executed with @DO 2.