The Current Program in the Interpreter [ HP Business BASIC/XL Reference Manual ] MPE/iX 5.0 Documentation
HP Business BASIC/XL Reference Manual
The Current Program in the Interpreter
Within the interpreter, the program being created, modified, executed, or
debugged resides in the interpreter's work space. This program is
referred to as the current program.
The current program can be permanently saved in a disk file by using the
SAVE and RESAVE commands. The GET command is used to read the contents
of a permanent disk file into the interpreter's work space.
Line Ranges
Many commands and statements in this chapter operate on ranges of program
lines. In syntax specifications, line_range is a range of lines and
line_range_list is a list of line ranges.
The syntax of line_range_list is shown below.
Syntax
line_range [, line_range]...
Parameters
line_range One of the following:
ALL
su_spec
ln_spec1 [/ln_spec2]
ALL All program lines. In a command or statement where
line_range or line_range_list is optional, ALL is the
default unless otherwise specified.
su_spec One of the following program unit specifiers:
SUB sub_id Range is all of sub_id, which
must exist.
[SUB] FNfunc_id Range is all of FNfunc_id, which
must exist.
MAIN Range is all of the main
program, which must exist.
ln_spec1 First line in range, specified by one of the following:
line_num If line_num does not exist,
line_range is null (see Table
2-1 and Table 2-2).
line_num {+|-} offset The line that is offset lines
from the line numbered line_num
(see offset, below). The line
numbered line_num must exist in
the program. If line_num {+|-}
offset does not exist, the
existing line nearest it is used
(see Table 2-1 and Table 2-2).
FIRST First program line.
LAST Last program line.
* Last line executed (undefined
for a stopped program). The
command LIST * displays this
line.
line_label Must be defined in the currently
executing program unit.
line_label {+|-} The line that is offset lines
offset from the line labeled line_label
(see offset, below). The label
line_label must be defined in
the currently executing program
unit. If line_label {+|-}
offset does not exist, the line
nearest it is used (see Table
2-1 and Table 2-2).
MAIN The first line of the main
program. The main program must
exist.
SUB sub_id The first line of the subprogram
sub_id. The subprogram must
exist.
[SUB] FNfunc_id The first line of the function
FNfunc_id. The function must
exist.
offset Number of actual lines past (or
before) line_num. For example,
10+3 is the line three lines
from line 10. This is not
necessarily line 13. In the
following program, it is line
50:
10 PRINT "HI"
20 X=4
30 PRINT X
50 END
ln_spec2 Last line in range. The line_num through line_label
{+|-} offset are the same as specified for ln_spec1.
MAIN, SUB and FN change to the corresponding last line
in each.
MAIN Last line in main program. The
default is ln_spec1.
SUB sub_id Last line in sub_id.
[SUB] FNfunc_id Last line in FNfunc_id.
Examples
The following shows examples of specifying line ranges.
ALL !Specifies all lines
SUB Sub1 !Specifies all lines in Sub1
FNAdd, FNScramble$ !Specifies all of FNAdd and FNScrable$
MAIN, FNAdd/FNScramble$ !Specifies all of FNAdd, FNScramble, and
!all of the main program
100,1000+50,Label+50 !Specifies lines 100, and the lines that are 50
!lines past 1000 and 50 lines past Label
FIRST+100/LAST-350 !Specifies 100 lines past FIRST through 350 lines
!before LAST
*/LAST !Specifies the last executed line through the
!last program line
*-50/*+10,SUB Sub1/LAST !Specifies 50 lines before the last executed
!line through 10 lines after the last executed
!line, and the first line of Sub1 through the
!last program line
FIRST/FNAdd !Specifies the first program line through the
!last line of FNAdd
MAIN/2000 !Specifies the first line of the main program
!through line 2000
100/150 !Specifies lines 100 through 150
Table 2-1 shows where the line range begins when ln_spec1 is not in the
program. Table 2-2 shows where the line range ends when ln_spec2 is not
in the program.
Table 2-1. Where Line Range Begins When ln_spec1 is Not in Program
------------------------------------------------------------------------------------------------
| | | | |
| ln_spec1 | ln_spec2 is | Program does not | Program does not have |
| | Specified | have line_num | line_num {+ | -} |
| | | | offset |
| | | | (but has line_num) |
| | | | |
------------------------------------------------------------------------------------------------
| | | | |
| line_num | No | Nothing happens. | Not applicable. |
| | | | |
------------------------------------------------------------------------------------------------
| | | | |
| line_num | Yes | Range begins with | Not applicable. |
| | | existing line number that | |
| | | is closest to but greater | |
| | | than line_num. | |
| | | | |
------------------------------------------------------------------------------------------------
| | | | |
| line_num{+|-}offset | Irrelevant | Error occurs. | If |
| | | | line_num{+|-}offset |
| | | | |
| | | | is before first |
| | | | program line, range |
| | | | begins with first |
| | | | program line. |
| | | | |
| | | | If |
| | | | line_num{+|-}offset |
| | | | |
| | | | is after last program |
| | | | line, range begins |
| | | | with last program |
| | | | line. |
| | | | |
------------------------------------------------------------------------------------------------
Table 2-2. Where Line Range Ends When ln_spec2 is Not in Program
----------------------------------------------------------------------------------------------
| | | |
| ln_spec2 | Program does not have | Program does not have |
| | line_num | line_num{+ | -}offset |
| | | (but has line_num) |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| line_num | Range ends with existing | Not applicable. |
| | line number that is | |
| | closest to but less than | |
| | line_num. | |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| line_num{+| -}offset | Error occurs. | If line_num{+|-}offset |
| | | |
| | | is before first program |
| | | line, range ends with |
| | | first program line. |
| | | |
| | | If line_num{+|-}offset |
| | | |
| | | is after last program |
| | | line, range ends with |
| | | last program line. |
| | | |
----------------------------------------------------------------------------------------------
Examples
Refer to this program when reading the examples that follow it:
100 A=3
110 B=4
120 PRINT A,B
130 Add: C=A+B
140 PRINT C
150 END
160 DEF FNTwo
170 PRINT "In FNTwo"
180 RETURN 2
190 FNEND
Range Specified Range Used (or Effect)
10 Nothing happens
10/120 100/120
10/125 100/120
110 110
10+1 Error
10+1/130 Error
100+2 120
100+2/140 120/140
100+2/145 120/140
100+2/150-1 120/140
200-3 Error
100/200-3 Error
110-3/140-1 100/130
130+5 180
Add 130 If the main unit is currently executing, otherwise
an error results.
Add-1/Add+1 120/140 If the main unit is currently executing,
otherwise an error results.
MAIN 100/150
FNTwo 160/190
Halt Key
Pressing CONTROL Y while a program is executing suspends the program.
Any I/O (Input or Output) operation that is in process finishes before
program execution is suspended. For example, if the program is reading a
disk file, that read will complete before the program is suspended. When
the HALT is executed, the cursor appears on the terminal screen. To
resume program execution, use the CONTINUE command, described later in
this chapter.
Pressing the halt key twice in rapid succession suspends the program, but
any I/O operation that is in progress is aborted.
MPE/iX 5.0 Documentation