Goto. DORIC 9.65, INFO-Text software
Reklama
Reklama
GOTO
GOTO
label_name
transfers control to the specified LABEL command, which must reside in the same program section.
argument notes examples
label_name location in a program specified by the LABEL command.
n
GOTO allows you to go from one set of INFO program statements to another. Corresponding GOTO and LABEL commands must be in the same program section.
n
You can have up to 200 GOTO statements within any one program section.
n
Any number of GOTO statements can refer to the same
LABEL label name.
n
When you write programs that have a GOTO command in an odd-numbered program section, make sure that file and format assignments are referenced correctly.
In the following program sequence, the commands that follow the command LABEL WORK process records in the data file D.TAX whenever the GOTO command (program line 10010) is executed.
10001 SELECT D.EMPS
10002 LABEL WORK
.
.
.
.
10008 SELECT D.TAX
10009 IF $NUM2 LE 10
10010 GOTO WORK
The data file D.EMPS
is selected.
GOTO returns to here; BUT D.TAX
is still selected.
D.TAX is selected.
INFO Reference Manual Commands 261
GOTO
When INFO processes the GOTO WORK command, it passes control to line 10002. D.TAX is still the selected file but D.EMPS is needed. To avoid this situation, simply place the LABEL statement before the command line that selects D.EMPS.
10001 LABEL WORK
10002 SELECT D.EMPS
D.EMPS is selected.
10008 SELECT D.TAX
10009 IF $NUM2 LE 10
10010 GOTO WORK
While GOTO is most often used for simple branching to another program command, you can use it to establish a program loop, similar to a DO...DOEND sequence.
.
.
.
20000 PROGRAM SECTION TWO
20001 LABEL START
20002 CURSOR 20,22
20003 DISPLAY 'ENTER OPTION:',=
20004 ACCEPT $NUM1
Destination of loop
20005 IF $NUM1 LT 1 OR $NUM1 GT 12
20006 DISPLAY 'ERROR — VALUE MUST BE 1 TO 12'
20007 GOTO START
Loops back to START
20008 ELSE
if an invalid number is entered.
.
.
.
20015 ENDIF
262 Commands INFO Reference Manual
Stáhnout
Reklama