HP Business BASIC/XL Reference Manual - HP 3000 MPE/iX Computer Systems - Edition 1 (32715-90001)
4-: 59
12 RETURN !Return to line 3
20 REM Subroutine for I=2
21 PRINT "I is two"
22 RETURN !Return to line 3
30 REM Subroutine for I=3
31 PRINT "I is three"
32 RETURN !Return to line 3
40 REM Subroutine for J=1
41 PRINT "J is one"
42 RETURN !Return to line 4
50 REM Subroutine for J=2
51 PRINT "J is two"
52 RETURN !Return to line 4
60 REM Subroutine for J=3
61 PRINT "J is three"
62 RETURN !Return to line 4
90 DATA 3,2
99 END
In the above program, line 2 will be listed as GOSUB I OF 10,20,30.
The ON GOSUB statement works like the GOSUB OF statement. The following
statements are equivalent:
150 ON I GOSUB 10, 20, 30, Quit
150 GOSUB I OF 10, 20, 30, Quit
GOTO
The GOTO statement unconditionally transfers control to a specified line.
The line must be in the same program unit as the GOTO statement. If the
line is not executable (a comment or declaration, for example) HP
Business BASIC/XL executes the first executable statement following it.
Syntax
{GOTO }
{GO TO}
line_id
Parameters
line_id
Line number or line label of the line that control
transfers to. It must be in the same program unit as
the GOTO statement. Although the GOTO statement can be
entered as either GO TO or GOTO, HP Business BASIC/XL
will always list it as GOTO.
Examples
10 GOTO 30 !Transfer control to line 30
20 A = 1 !Never executed
30 A = 2 !Executed immediately after line 10
40 GO TO Remark !Transfer control to line 60
50 PRINT "HI" !Never executed
60 Remark: !Unexecutable statement; execute next line
70 PRINT A !Executed after line 40
99 END
Line 40 will list as GOTO Remark.
GOTO OF
The GOTO OF statement transfers control to one of several lines,
depending on the value of a numeric expression. Although this statement
can be entered as either GOTO OF or GO TO OF, HP Business BASIC/XL will
always list it as GOTO OF.
Syntax