HP Business BASIC/XL Reference Manual - HP 3000 MPE/iX Computer Systems - Edition 1 (32715-90001)

4-: 57
100 GETKEY
200 GETKEY keydef2 !Uses file Keydef2
300 GET KEY Filename$ + "." + Groupname$ !Uses the file named in
310 !Filename$ in group Groupname$
GLOBAL EXTERNAL
The GLOBAL keyword modifier to the EXTERNAL statement. It allows either
the main block or any procedure or function within a program to call an
external. It's use and syntax are explained in the EXTERNAL statement.
GLOBAL INTRINSIC
The GLOBAL keyword is a modifier to the INTRINSIC statement. It allows
an intrinsic definition to affect every program unit in the program.
It's use and syntax are explained in the INTRINSIC statement.
GLOBAL OPTION
The GLOBAL keyword is a modifier to the OPTION statement. It makes
selected options global to every program unit in the program. It's use
and syntax are explained in the OPTION statement.
GOSUB
The GOSUB statement unconditionally transfers control to a specified
line. The line must be in the same program unit as the GOSUB statement.
If that line is not executable (for example, if it is a comment or
declaration), control transfers to the first executable statement
following it. GOSUB can be entered as GO SUB, but HP Business BASIC/XL
will always list it as GOSUB.
GOSUB routines can be nested. It is however, a good programming practice
to treat these routines as local subunits, that is always using the GOSUB
routine to execute them and the RETURN statement to return from them. It
is possible to use the GOTO statement into and out of subroutines, but
this not a good structured programming practice and should be avoided.
The number of levels of nesting is limited. It is set with the COPTION
MAXGOSUB. The default for this COPTION is 10.
The RETURN statement returns control to the line following the GOSUB
statement (see the RETURN statement in this chapter).
Syntax
{GOSUB }
{GO SUB}
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 GOSUB statement.
Examples
10 REM Main Program Unit
20 GOSUB 90 !Transfer to line 90
30 REM Print sides of square
40 PRINT "| |"
50 PRINT "| |"
70 GO SUB 90 !Is listed as GOSUB 90
80 STOP
90 REM Subroutine to print top and bottom of the square
100 PRINT "+----+"
120 RETURN
999 END