Creation and Modification Commands (continued) [ HP Business BASIC/XL Reference Manual ] MPE/iX 5.0 Documentation
HP Business BASIC/XL Reference Manual
Creation and Modification Commands (continued)
INDENT Command
The INDENT command indents the bodies of constructs. This tool makes it
easy to see the nesting level of the program's constructs. The INDENT
command modifies lines without displaying them.
Syntax
INDENT [num_expr1 [, num_expr2] ]
Parameters
num_expr1 The value num_expr1+8 is the starting column number of
every line that is not in the body of a structured
statement. The value of num_expr1 must be in the range
[1,63]. Default is one.
num_expr2 Increment for calculating starting column numbers of
nested (indented) lines. If a line is in the body of
one structured statement, it is nested (and indented)
once and begins in column(num_expr1+8)+num_expr2. If a
line is in the body of n structured statements, it is
nested (and indented) n times, and begins in column
(num_expr1+8)+(n*num_expr2). The value of num_expr2
must be in the range [0,63]. The default is three.
The INDENT statement indents the part of the line that follows the line
number and label. It does not indent the line number or the label of a
line. The line number is always right-justified in columns two through
seven. For a labeled line, the indented line will contain the line
number, one blank space, the label and a colon (:). The rest of the line
begins in the column specified by the INDENT command, with two
exceptions:
* If the label or colon occupies the specified column, then the rest of
the line begins in the next available column.
* If the specified column is beyond 72, then the rest of the line
begins in column 72.
A comment (beginning with "!") is listed in the column originally entered
(relative to the line number), if possible. If this is not possible
because the statement occupies that column, then the comment begins in
the next available column.
If a modified line is too long, the LIST command displays:
* The line, except characters beyond the maximum line length.
* An asterisk (*) in the last column of the line (the asterisk is
character 500).
Examples
The following example shows the effect of the INDENT command. First, the
starting column of each line is set to seven and each nested line is
indented three. The second INDENT command changes the starting column to
three, and the indentation to five.
>list
! exam217
5 ! BEGIN PROGRAM
10 DIM A(5),B$(2,4)[2]
20 INTEGER X,Y,Z
30 Loop1: FOR I=1 TO 5 !Fill A
40 A(I)=I
45 PRINT I
50 NEXT I
60 Loop2: FOR I=1 TO 2 !Fill B
70 FOR J=1 TO 4
75 REM INNER LOOP
80 B$(I,J)=CHR$(I)+CHR$(J)
85 PRINT I,J
90 NEXT J
100 NEXT I
999 END
>indent 7,3
>list
! exam217
5 ! BEGIN PROGRAM
10 DIM A(5),B$(2,4)[2]
20 INTEGER X,Y,Z
30 Loop1: FOR I=1 TO 5 !Fill A
40 A(I)=I
45 PRINT I
50 NEXT I
60 Loop2: FOR I=1 TO 2 !Fill B
70 FOR J=1 TO 4
75 REM INNER LOOP
80 B$(I,J)=CHR$(I)+CHR$(J)
85 PRINT I,J
90 NEXT J
100 NEXT I
999 END
>indent 3,5
>list
! exam217
5 ! BEGIN PROGRAM
10 DIM A(5),B$(2,4)[2]
20 INTEGER X,Y,Z
30 Loop1: FOR I=1 TO 5 !Fill A
40 A(I)=I
45 PRINT I
50 NEXT I
60 Loop2: FOR I=1 TO 2 !Fill B
70 FOR J=1 TO 4
75 REM INNER LOOP
80 B$(I,J)=CHR$(I)+CHR$(J)
85 PRINT I,J
90 NEXT J
100 NEXT I
999 END
>
LIST Command
The LIST command lists all or part of a program to the destination
specified by the SEND SYSTEM OUTPUT TO statement (usually the terminal)
or to a specified device (usually a spooled printer). The LIST command
is a command-only statement. That is, it can only be issued at the
interpreter prompt and cannot be placed in a program. Compiler
formatting options can be used to print page titles or page numbers,
control the number of lines printed per page and print a list of the
identifiers in the program.
Syntax
[ {NONAME }]
LIST [line_range_list] [TO dev_spec] [;{FORMATTED}]
[ {FORMAT }]
Parameters
dev_spec See "Device Specification Syntax," in chapter 6. If
this parameter is specified, the LIST command lists the
lines on the specified device (dev_spec); otherwise, it
appends them to the file specified by the most recently
executed SEND SYSTEM OUTPUT TO statement.
NONAME The program name is not listed if this parameter is
specified. This is relevant only when the program has a
name, that is, if it was retrieved by the GET command or
named with the NAME command. If you have just typed in
the program, and have not used the NAME command, the
program will not have a name.
FORMATTED The listing is formatted using a set of the compiler
FORMAT listing options that appear in the program if this
parameter is specified. The set of COPTIONS used to
format the interpreter listing are: LINES, LIST, ID
TABLES, PAGE, PAGESUB, TITLE, and TITLESUB. These are
explained in chapter 9.
The LIST command may add or remove blanks and parentheses to make lines
more readable. It also does the following:
* Lists lines in line number order, whether or not they were entered in
that order.
* Lists identifiers with first letters upshifted and all other letters
downshifted.
* Lists keywords in all uppercase letters.
* Lists empty statements as empty comments (for example, it lists the
line "500 Label:" as "500 Label: !").
The column at which long lines are broken depends on the output device
and WIDTH. On a terminal screen, the default line length is 80; on a line
printer, it is 132.
If a line exceeds the maximum length, the LIST command prints an asterisk
(*) in its last column and truncates the line at the maximum length.
To stop the LIST command, press CONTROL Y.
Examples
The following example shows the LIST command. Without parameters, the
LIST command below displays the entire program. When LIST has the
parameter 10/90, lines 10 through 90 are displayed.
>10 real ALPHA, BeTa,delta
>5 SHORT c, d, e
>100 !
>73 Correction:
>LIST
5 SHORT C,D,E
10 REAL Alpha,Beta,Delta
73 Correction: !
100 !
>LIST 10/90
10 REAL Alpha,Beta,Delta
73 Correction: !
>
LIST SUBS Command
The LIST SUBS command prints the name and starting line number of every
subunit in the program, and indicates the currently executing program
unit with an asterisk (*). The LIST SUBS command is a command-only
statement. That is, it can only be issued at the interpreter prompt and
cannot be placed in a program.
Syntax
LIST SUBS
Example
The following example shows the use of the LIST SUBS command. When you
type LIST SUBS, the first line and subunit name are displayed for each
subunit in the program.
>LIST
10 PRINT "this is the main"
20 CALL A
100 SUB A
110 PRINT " in sub a"
120 PRINT FNX
130 SUBEND
100000 DEF FNX
100100 PRINT " in fnx"
100200 RETURN 5
100300 FNEND
>LIST SUBS
First Line Subunit name
---------- ------------
10 MAIN *
100 A
100000 FNX
MODIFY Command
The MODIFY command replaces, deletes, or inserts characters in one or
more program lines. The MODIFY command is a command-only statement.
That is, it can only be issued at the interpreter prompt, and cannot be
placed in a program.
Syntax
{MODIFY}
{MOD } [line_range_list]
The MODIFY command displays the lines of line_range_list one at a time.
If a program line occupies more than one physical line, each physical
line is displayed separately. When a line is displayed, the cursor is
positioned immediately under the beginning of that portion of the line to
be modified. Choose one of the editing commands in Table 2-4 or type the
characters to be replaced.
After editing the line, press RETURN. The MODIFY command displays the
modified line for further modification. When you are finished with the
modifications, type RETURN after the modified line is displayed. HP
Business BASIC/XL modifies the line and, if it is correct, incorporates
the modified line into the program. Then the next line in the
line_range_list is displayed for modification. If the modified line has
a syntax error, the error message associated with that error is displayed
and you return to the MODIFY mode for that line.
If you have difficulty modifying the line and wish to start with the
version of the line that you had when you began, type "//" or CONTROL Y.
Table 2-4. MODIFY Subcommands
-----------------------------------------------------------------------------------------------
| | | |
| Subcommand | Modification | Usage |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| D (or d) | Delete one character or a series | Type D under each character to be |
| | of characters. | deleted. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| D (or d) | Delete a series of characters. | Type D under the first and last |
| | | characters to be deleted. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| D (or d)E (or e) | Delete from one character to the | Type D under the first character |
| | end of the line. | to be deleted and E (or e) |
| | | immediately after D. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| D(or d)& | Delete from one character to the | Type D under the first character |
| | continuation character (&). | to be deleted and & immediately |
| | | after D. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| I (or i) | Insert characters. | Type I under the character before |
| | | which characters are to be |
| | | inserted; after I, type the |
| | | characters to be inserted. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| R (or r) | Replace characters. | Type R under the first character |
| | | of the string to be replaced. |
| | | After R, type the n characters |
| | | that will replace the first |
| | | character and the next n-1 |
| | | characters. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| // or CONTROL Y | Cancel modifications on current | Type one of the following under |
| | line. | the line: // or CONTROL Y. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| Any other | Replace characters. | Type the characters that will |
| character | | replace those in the preceding |
| | | line. |
| | | |
-----------------------------------------------------------------------------------------------
If a modified line is too long, the MODIFY command displays the
following:
* The line, except characters beyond the maximum line length.
* An asterisk (*) in the last column (the asterisk is character 500).
To cancel modifications on a line, type "//" or CONTROL Y. The original
line will be displayed for modification.
To stop the MODIFY command, type "//" or CONTROL Y before modifying the
currently displayed line, or type "//" or CONTROL Y immediately followed
by "//" or CONTROL Y.
Examples
The following examples show the use of the MODIFY command. Lines 30,40,
50, and lines 100 through 180 are modified. "//" is used to cancel the
modification of line 150.
>LIST
10 REM 5/21/84
20 PRINT "BEGIN"
30 SHORT INTEGER A,B
40 SHORT INTEGER C,D
50 INTEGER E,F,G,H,I
60 READ A,B
70 READ C,D
80 READ E,F
90 DATA 1,2,3,4,5,6,7,8,9
100 PRINT "A,B,E,F"
110 PRINT A,B,E,F
120 PRINT G,H,I
130 PRINT A,B,H,I
140 PRINT I,H,G,A,B,C
150 PRINT E,F,G,H
160 PRINT F,A,B,C,D,E
170 PRINT
180 PRINT "END"
999 END
>MODIFY 30/50,100/180
30 SHORT INTEGER A,B
DDDDDD RETURN
30 INTEGER A,B
RETURN
40 SHORT INTEGER C,D
D D RETURN
40 INTEGER C,D
RETURN
50 INTEGER E,F,G,H,I
DE RETURN
50 INTEGER E,F
RETURN
100 PRINT "A,B,E,F"
IC,D, RETURN
100 PRINT "A,B,C,D,E,F"
RETURN
110 PRINT A,B,E,F
RC,D,E,F RETURN
110 PRINT A,B,C,D,E,F
RETURN
120 PRINT G,H,I
B,C,D,E,F,A RETURN
120 PRINT B,C,D,E,F,A
RETURN
130 PRINT A,B,H,I
IC,D,E,F, RETURN
130 PRINT C,D,E,F,A,B,H,I
DE RETURN
130 PRINT C,D,E,F,A,B
RETURN
140 PRINT I,H,G,A,B,C
D DID,E,F RETURN
140 PRINT D,E,F,A,B,C
RETURN
150 PRINT E,F,G,H
DE RETURN
150 PRINT
// RETURN
150 PRINT E,F,G,H
RA,B,C,D RETURN
150 PRINT E,F,A,B,C,D
RETURN
160 PRINT F,A,B,C,D,E
// RETURN
>LIST
10 REM 5/21/84
20 PRINT "BEGIN"
30 INTEGER A,B
40 INTEGER C,D
50 INTEGER E,F
60 READ A,B
70 READ C,D
80 READ E,F
90 DATA 1,2,3,4,5,6,7,8,9
100 PRINT "A,B,C,D,E,F"
110 PRINT A,B,C,D,E,F
120 PRINT B,C,D,E,F,A
130 PRINT C,D,E,F,A,B
140 PRINT D,E,F,A,B,C
150 PRINT E,F,A,B,C,D
160 PRINT F,A,B,C,D,E
170 PRINT
180 PRINT "END"
999 END
>
NAME Command
The NAME command names or renames the current program. The NAME command
is a command-only statement. That is, it can only be issued at the
interpreter prompt and cannot be placed in a program.
Syntax
NAME [fname]
Parameters
fname A name for the current program. fname is a valid MPE
file name that conforms to MPE file name rules. If
fname is not specified, the program has no name.
Therefore, the NAME command can be used to delete a
program's name. The SAVE and RESAVE commands use fname
as the program name.
Examples
NAME "Test1" !The current program is called Test1
NAME "File2.grp" !The current program is called File2.grp
NAME !The current program now has no name
REDO Command
The REDO command allows you to replace, delete, or insert characters in
the last line that was accessed. The line may have been entered or it
may have been accessed by any of the MODIFY, GET, LINK, MERGE, CHANGE, or
REDO commands. The REDO command works exactly like the MODIFY command,
except that it can modify a command as well as a program line. The REDO
command is a command-only statement. That is, it can only be issued at
the interpreter prompt and cannot be placed in a program.
Note that the GET command accesses each line of the program.
Consequently, a REDO following a GET will display the last line that the
GET has accessed.
Syntax
REDO
Example
The following example shows the use of the REDO command to correct syntax
errors.
>20 INTGGER N,P,R RETURN
20 INTGGER N,P,R
^
Syntax error at character 12
Statement needs =
>REDO RETURN
20 INTGGER N,P,R
E
20 INTEGER N,P,R
Iumber RETURN
20 INTEGER Number,P,R
RETURN
>LIST 20 RETURN
20 INTEGER Number,P,R
>
RENUMBER Command
The RENUMBER command renumbers one range of program lines. The range can
be the whole program. The RENUMBER command is a command-only statement.
That is, it can only be issued at the interpreter prompt, and cannot be
placed in a program.
Syntax
{RENUMBER} {TO}
{RENUM } [line_range] {, } [beginning_line_number] [BY increment]
{REN }
Parameters
line_range Lines to be renumbered. If you are specifying
line numbers, use the line numbers that you had
before issuing the RENUMBER command. The
default is all program lines.
beginning_line_number New line number for the first line to be
renumbered. The default is 10.
increment Increment. Number of lines between each
renumbered line. The default is 10.
Secured lines remain secure when they are renumbered.
The RENUMBER command is not executed if it would rearrange lines. The
lines that surround the lines that are being renumbered must still
surround them after they are renumbered.
If a RENUMBER command would renumber a line with a number greater than
999999, then an error occurs and the command is not executed.
The RENUMBER command renumbers every line in the line_range. It also
substitutes the new line number for the old one in every reference to an
existing line (for example, if line 100 becomes line 350, the statement
"GOTO 100" becomes "GOTO 350"). The RENUMBER command does not change
line numbers that reference nonexistent lines.
Examples
>LIST
100 GOTO 200
120 RESTORE 190
190 GOTO 110 !(Line 110 does not exist)
200 DATA ABC
>RENUMBER
>LIST
10 GOTO 40
20 RESTORE 30
30 GOTO 110 !(110 does not change)
40 DATA ABC
>RENUM 20/40 TO 100 BY 5
>LIST
10 GOTO 110
100 RESTORE 105
105 GOTO 110 !(110 does not change, but now exists)
110 DATA ABC
>REN TO 500
>LIST
500 GOTO 530
510 RESTORE 520
520 GOTO 530 !(110 becomes 530)
530 DATA ABC
SCRATCH Statement
The SCRATCH statement can be used to reset variables to their default
values, erase the current program, reset the values returned by
functions, or reset the entire interpreter environment.
Syntax
[ALL ]
[PROG]
SCRATCH [COM ]
[VARS]
Parameters
ALL Set the HP Business BASIC/XL interpreter environment to
the same state as that on initial entry following the
BBXL command.
COM Deallocates all variables. Also stops program execution
if the SCRATCH statement is in a subunit.
PROG Erases the current program in the interpreter's work
space. PROG is the default option set for SCRATCH.
VARS Deallocates all variables except those in common areas.
Also stops program execution if the SCRATCH statement is
in a subunit.
The options used with the SCRATCH statement permit you to select the
level of features to be reset. Thus, SCRATCH VARS resets only those
features listed below the heading in the following list. SCRATCH COM
reinitializes the common area variables as well as resetting the features
performed in a SCRATCH VARS. Likewise, SCRATCH PROG resets the SCRATCH
PROG, SCRATCH COM and SCRATCH VARS features. Using SCRATCH ALL resets
all the features indicated for each of the SCRATCH options and resets the
interpreter back to its initial state. The following list summarizes the
features reset with each option level:
SCRATCH ALL.
* Interpreter's Configuration File read and configurable options reset.
* FILES ARE IN reset to home group and account under which HP Business
BASIC/XL is running.
* SEND OUTPUT TO reset to DISPLAY.
* SEND SYSTEM OUTPUT TO reset to DISPLAY.
* COPY ALL OUTPUT TO reset to DISPLAY.
* Output line width set to printer line width if HP Business BASIC/XL
is running in batch mode.
* Output line width set to terminal line width if HP Business BASIC/XL
is running interactively.
* FLUSH INPUT buffer.
* Branch-during-input keys cleared.
* Typing definitions of the programmable function keys restored.
SCRATCH COM.
* COMMON area variables reset according to INIT options selected.
SCRATCH PROG.
* Current program erased.
* Current program name erased.
* Current program lockword erased.
* DEFAULT option to assign values to variables on arithmetic overflow
or underflow set OFF.
* Random seed number set to default value of PI/180.
* STANDARD numeric output format set.
* Angular units set to RADIANS.
* BREAK key enabled.
* Response function return value set to 0.
* CURKEY function return value set to 0.
* DBASE is reset.
* WORKFILE is reset.
* Form filename reset.
SCRATCH VARS.
* Non-COMMON area variables reset according to INIT option specified.
* Any Tracing is turned off.
* ERRL return value set to 0.
* ERRN return value set to 0.
* All open files that have been opened with the HP Business BASIC/XL
ASSIGN statement that are not in a common area are closed.
SECURE Statement
The SECURE statement prevents program lines from being listed or
modified.
Syntax
SECURE line_range_list
You cannot perform the following on a secured line:
* Modify.
* List (except for the line number, followed by an asterisk).
* Move or copy.
You can perform the following on a secured line:
* Delete.
* Renumber.
Example
The following shows the results of using the SECURE statement:
>LIST
100 INTEGER A,B,C
110 LET A=1
120 LET B=2
130 LET C=3
140 PRINT A+B+C
999 END
>SECURE 110/130
>LIST
100 INTEGER A,B,C
110 *
120 *
130 *
140 PRINT A+B+C
999 END
>MODIFY 120
Line 120 secured and cannot be modified.
In the above example, lines 110 through 130 were secured.
XREF Command
XREF is an interpreter command that generates a cross reference of the
entire current program, just the main program unit, or any procedure or
function of the current program. A cross reference is a list of the
identifiers in the specified part of the current program that includes
the following information: name, type, class, and line numbers on which
it is used. The cross reference is sorted according to identifier names.
Syntax :
[WITH LIST ]
XREF [sub_name [,sub_name]...] [WITH SOURCE] [TO listfile]
Parameters
sub_name Either MAIN or the name of the procedure or function for
which the cross reference is to be generated. A cross
reference is generated from the entire program if this
is not specified.
WITH LIST If this parameter is specified, the cross reference
WITH SOURCE immediately follows the listing of the source code for
each individual part (MAIN, procedure, or function). If
it is not specified, the identifiers from the main are
listed under a banner containing the word MAIN, and
identifiers from each procedure or function are listed
under a one-line banner with the name of the procedure
or function.
listfile The name of the file the cross reference is to be
printed to. If not specified, the cross reference is
printed to the destination specified by the SEND SYSTEM
OUTPUT TO statement (usually the terminal).
The cross reference is generated on a subunit basis. The following
information is provided for each identifier:
Name Name of the identifier.
Class Class to which the identifier belongs. Class
information is designed to convey dimensionality and
usage information. Dimensionality is specified by
SIMPLE, identifiers declared implicitly or explicitly as
scalars, and array identifiers declared implicitly or
explicitly with the DIM statement as arrays. For
numeric and string variables, usage is also
characterized by the location of the declaration of the
variable in the program, PARAMETER, or COMMON. If
neither of those is specified, the variable is local.
Identifiers that are not variables are characterized by
their usage in the program as SUBPROGRAM, FUNCTION,
EXTERNAL, or LABEL.
Type The data type of the identifier: SHORT REAL, REAL,
SHORT INTEGER, INTEGER, SHORT DECIMAL, DECIMAL, or
STRING.
Declaration Whether the numeric or string variable has been
explicitly declared.
Occurrence The line numbers of the statements that the identifier
occurs in. The line numbers of statements in which a
new value is potentially assigned to the identifier are
followed by an (*). The line number of the statement
that the identifier is declared in is followed by an
ampersand (@).
If either WITH LIST or WITH SOURCE is specified, the formatting of the
cross reference's output is controlled by any of the compiler options
such as LINES, LIST, PAGE, PAGESUB, TITLE, and TITLESUB present in the
program. Otherwise, the default compiler options are in effect.
NOTE Because of the large amount of internal information that must be
evaluated when creating a cross-reference, a cross-reference for a
large program can take a considerable amount of time. As a result,
there may be a long delay before the first output is printed or
displayed.
The following is a sample output of the cross reference:
PAGE 1 HP Business BASIC/XL HP32715A.00.00 (c) Hewlett-Packard Co.
1989 MON, MAY 18, 1989 4:44 PM
* * * * * * * * * * * * * * * * * MAIN * * * * * * * * * * * * * * * * *
A SIMPLE SHORT INTEGER
250@ 470* 1210* 1590* 1660 3420* 3430 3450 3550*
3560 3590
A$ SIMPLE STRING
230@ 1250* 1260* 1270 1290 1520* 1530 1540 1610*
1630 1650 1790* 1800 1820 2070* 2080 2100 2210*
2220 2230* 2250 2290 2300 2570* 2710* 2760 3030*
3060* 3070 3670 3680
B SIMPLE SHORT INTEGER
250@ 3430
B ARRAY SHORT INTEGER
280@
B$ SIMPLE STRING
230@ 1760* 1780 2040* 2060
B1 SIMPLE SHORT INTEGER
260@
B2 SIMPLE SHORT INTEGER
260@
I1 SIMPLE COMMON SHORT INTEGER
220@ 1920* 1930 1940 2800* 2810 2820 2850* 2880
2890 2910* 2920 2930 2940 2950 2970 3190* 3200
3210 3280* 3290 3670* 3680 3750
Z SIMPLE COMMON SHORT INTEGER
220@ 1270* 1280 1630* 1640 1800* 1810 2080* 2090
2220* 2240 2760* 2770 3160* 3680 3700 3720
Examples
>XREF !Default parameters
>XREF TO Printer !Listing to Printer
>XREF WITH LIST !Cross reference will follow the source
!for each program part
>XREF MAIN,Sub1,FNX TO Display !Listing for selected program units,
!to the terminal
>XREF SUB Sub2 WITH LIST !Cross reference for Sub2
MPE/iX 5.0 Documentation