Goto – Remote Processing CAMBASIC User Manual

Page 88

Advertising
background image

Comm ands - 55

GOTO

Statement

SYNTAX:

GOTO line/label

PURPOSE:

To br anch unco nditionally out of the norm al progr am sequ ence to a spec ified line num ber or label.

REMARK S:

If line is the line number of an executable statement, that statement and those following are executed.
If it is a non-exec utable statem ent (such as a r emar k), e xecution con tinues at the fir st executable
statement encountered after line.

The G OTO statement c an be used in Im mediate M ode to ree nter a pr ogram at a desired point. This
can be useful in debugging.

NOTE: The execution time of the GOTO statement is independent of the location of the target line in the program. There
is no runtime search.

EXAMPLE:

10 PRINT"line 10"
20 PRINT"line 20"
RUN
line 10
line 20

GOTO 20
line 20

The following is an exam ple using line/labels:

10 ..start
20 PRINT "at start"
30 GOTO ..here
40 ..there
50 PRINT "over there"
60 END
70 ..here
80 PRINT "over here"
90 GOTO ..there
RUN
at start
over here
over there

NOTE: When a label is used with GOTO, a statement cannot follow GOTO on the same line.

ERROR:

< Can’t compile> – if the line/label does not exist

Advertising