IB Statements/goto

From CometWiki

< IB Statements
Revision as of 11:00, 20 May 2009 by Badge (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

GOTO statement

Syntax: GOTO statement-label

GO TO statement-label

GO statement-label


Discussion: The GOTO statement transfers program control to the specified statement-label. The Internet Basic compiler recognizes three variations of this statement, including GOTO (two words, no space), GO TO (two words, one space), or GO (one word only).

Note: With the GOTO statement, there is no built-in provision for returning to the point where the GOTO statement was issued (this provision exists with the GOSUB statement, as well as other subroutine generating statements).

Also see ON/GOTO.

Example 1: TOP: READ (1,1000) EXCP=9000

.

GOTO TOP

In the above example, the GOTO statement is used to create a program loop. The statement labelled TOP represents the start of the loop. Other program statements are presumed to follow. At the end of these statements, the GOTO statement transfers program control back to TOP, thus creating a loop.

Example 2: IF ANSWER$ = "N" THEN GOTO 5000

In this example, the GOTO statement is used to transfer program control to statement label 5000 only if the string variable ANSWER$ is equal to "N" (a logical condition being tested by the IF/THEN statement).

Personal tools