Compaq BASIC for OpenVMS
Alpha and VAX
Systems
Reference Manual
LOAD
The LOAD command makes a previously created object module or modules
available for execution with the RUN command.
Format
Syntax Rules
File-spec must be a VAX BASIC object module or
VAX BASIC signals an error. The default file type is .OBJ. If you
specify only the file name, VAX BASIC searches for an .OBJ file in
the current default directory.
Remarks
- Each device and directory specification applies to all following
file specifications until you specify a new directory or device.
- The LOAD command accepts multiple device, directory, and file
specifications.
- VAX BASIC does not process the loaded object files until you
issue the RUN command. Consequently, errors in the loaded modules may
not be detected until you execute them.
- VAX BASIC signals an error in the following cases:
- If the file is not found
- If the file specification is not valid
- If the file is not a VAX BASIC object module
- If run-time memory is exceeded
Errors do not change the program currently in memory.
- The LOAD command clears all previously loaded object modules from
memory.
- Typing the LOAD command does not change the program currently in
memory.
Example
LOAD PROGA + PROGB + PROGC
|
LOCK
The LOCK command changes default values for COMPILE command qualifiers
and is a synonym for the SET command. See the SET command for more
information.
NEW
The NEW command clears VAX BASIC memory and allows you to assign a
name to a new program.
Format
Syntax Rules
Prog-name is the name of the program you want to create.
VAX BASIC allows program names to contain a maximum of 39
characters. You can use any combination of alphanumeric characters in
your program name, as well as the dollar sign ($), hyphen (-), and
underscore (_) characters.
Remarks
- VAX BASIC signals an error if prog-name exceeds 39
characters.
- VAX BASIC signals "error in program name" if you
specify a file type.
- If you do not specify a prog-name, VAX BASIC prompts
with:
- The default name is NONAME. If you do not provide a
prog-name in response to the prompt, VAX BASIC assigns the
file name NONAME to your program.
- When you enter the NEW command, the program currently in memory is
cleared. Program modules loaded with the LOAD command remain unchanged.
Example
OLD
The OLD command brings a previously created VAX BASIC program into
memory.
Format
Syntax Rules
- If you do not name a file-spec, VAX BASIC prompts for
one. If you do not enter a file-spec in response to the
prompt, BASIC searches for a file named NONAME.BAS in the current
default directory.
- The default file type is .BAS.
Remarks
- If the VAX BASIC compiler cannot find the file you specify,
BASIC signals the error "File not found."
- When the specified file is found, it is placed in memory and any
program currently in memory is erased. If VAX BASIC does not find
the specified file, the program currently in memory does not change.
Example
RENAME
The RENAME command allows you to assign a new name to the program
currently in memory. VAX BASIC does not write the renamed program
to a file until you save the program with the REPLACE or SAVE command.
Format
Syntax Rules
- Prog-name specifies the new program name. VAX BASIC
allows program names to contain a maximum of 39 characters. You can use
any combination of alphanumeric characters in your program name, as
well as the dollar sign ($), hyphen (-), and underscore (_) characters.
- If you specify a file type, VAX BASIC signals the error
"Error in program name."
Remarks
- The program you want to rename must be in memory. If you enter
RENAME with no program in memory, VAX BASIC renames the default
program, NONAME, to the specified prog-name.
- If you do not specify a prog-name, VAX BASIC renames
the program currently in memory NONAME.
- You must enter SAVE or REPLACE to write the renamed program to a
file. If you do not enter SAVE or REPLACE, VAX BASIC does not save
the renamed program.
- The RENAME command does not affect the original saved version of
the program.
Example
OLD TEST
Ready
RENAME NEWTEST
Ready
LIST
NEWTEST 06-OCT-1999 13:50
PRINT "This program is a simple test"
.
.
.
Ready
SAVE
%BASIC-I-FILEWRITE, NEWTEST written to file:
USER$$DISK:[SMITH.COMS]NEWTEST.BAS;5
Ready
|
In this example, the OLD command calls the program named TEST into
memory. The RENAME command renames TEST to NEWTEST and the SAVE command
writes NEWTEST.BAS to a file. The original file, TEST.BAS, is not
changed and is not deleted from your account.
REPLACE
The REPLACE command writes the current program back to the file
specified by the last OLD command.
Format
Syntax Rules
None
Remarks
- If you do not have write access to the directory containing the
original file, VAX BASIC signals an error message.
- VAX BASIC creates and saves a new version of the file,
incrementing the version number by 1 unless you supplied a specific
version number with the OLD command.
- A REPLACE command following a NEW command or a SCRATCH command
causes VAX BASIC to write the program in memory to the current
default directory.
- A REPLACE command following a RENAME command writes the file to the
directory specified in the OLD command with the file name specified in
the RENAME command.
Example
$ DIR USER$$DISK:[BASICUSER]TEST.BAS
Directory USER$$DISK:[BASICUSER]
TEST.BAS;1
Total of 1 file.
$ BASIC
VAX BASIC Vn.n
Ready
OLD USER$$DISK:[BASICUSER]TEST.BAS;
.
.
.
Ready
REPLACE
%BASIC-I-FILEWRITE, TEST written to file:
USER$$DISK:[BASICUSER]TEST.BAS;2
Ready
EXIT
$ DIR USER$$DISK:[BASICUSER]TEST.BAS
Directory USER$$DISK:[BASICUSER]
TEST.BAS;1 TEST.BAS;2
Total of 2 files.
$
|
RESEQUENCE
In a program with line numbers, the RESEQUENCE command allows you to
resequence the line numbers of the program currently in memory.
VAX BASIC also changes all references to the old line numbers so
they reference the new line numbers.
Format
Syntax Rules
- Line-num1 is the line number in the program currently in
memory where resequencing begins. The default for line-num1 is
the first line of the program module.
- Line-num2 is the optional end of the range of line numbers
to be resequenced. If you specify a range, VAX BASIC begins
resequencing with line-num1 and resequences through
line-num2. If you do not specify line-num2,
VAX BASIC resequences the specified line. If you do not specify
either line-num1 or line-num2, VAX BASIC
resequences the entire program.
- Line-num3 specifies the new first line number; the default
number for the new first line is 100. You can specify
line-num3 only when resequencing a range of lines.
If
line-num3 causes existing lines to be deleted or surrounded,
VAX BASIC signals an error.
- Int-const specifies the numbering increment for the
resequencing operation. The default for int-const is 10.
Remarks
- You cannot specify the RESEQUENCE command on programs that do not
contain line numbers.
- VAX BASIC signals an error when you try to resequence a program
that contains a %IF directive. VAX BASIC also signals an error when
you try to resequence a program that has a %INCLUDE directive if the
file to be included contains a reference to a line number.
- Before the RESEQUENCE command executes, VAX BASIC verifies the
syntax of the program. If the program is not syntactically valid, the
RESEQUENCE command does not execute.
- VAX BASIC sorts the renumbered program in ascending order when
the RESEQUENCE command executes.
- If the renumbering creates a line number greater than the maximum
line number of 32767, VAX BASIC signals an error.
- VAX BASIC signals an error if resequencing causes a change in
the order in which program statements are to execute and does not
resequence the program.
- VAX BASIC signals the error "Undefined line number"
in the case of undefined line numbers and does not resequence the
program.
- VAX BASIC corrects all line numbers for statements that
transfer control.
- VAX BASIC does not modify the program currently in memory when
the RESEQUENCE command generates an error.
- In general, the RESEQUENCE command is not recommended for programs
containing error handlers that test the value of ERL. However, the
RESEQUENCE command correctly modifies the program if the tests that
reference ERL are of the following form:
ERL relational-operator int-lit
|
The RESEQUENCE command does not correctly renumber programs if the
test compares ERL with an expression or a variable, or if ERL follows
the relational operator. The following line number references, for
example, would not be correctly renumbered:
IF ERL = 1000 + A% THEN ...
IF 1000 > ERL THEN ...
|
Example
10 INPUT "Enter a numeric value";A%
20 IF A% = 0 THEN GOTO 50
30 PRINT "Your number was ";A%
40 GOTO 10
50 PRINT "Goodbye"
60 END
|
Output
100 INPUT "Enter a numeric value";A%
105 IF A% = 0 THEN GOTO 120
110 PRINT "Your number was ";A%
115 GOTO 100
120 PRINT "Goodbye"
125 END
|
In this example, the command RESEQUENCE 10-60 STEP 5 causes
VAX BASIC to resequence lines 10 to 60, incrementing each new line
number by 5.
RUN and RUNNH
The RUN command allows you to execute a program from the VAX BASIC
Environment without first invoking the OpenVMS Linker to construct an
executable image. In addition, the RUN command allows you to access
user specified and system shareable image libraries for undefined
symbols. The RUNNH command is identical to RUN, except that it does not
display the program header, current date, and time.
Format
Syntax Rules
None
Remarks
- Executing a Program
- If you specify only the file name, VAX BASIC searches for a
file with a .BAS file type in the current default directory.
- If you do not supply a file-spec, VAX BASIC executes
the program currently in memory.
- VAX BASIC signals the warning message "No main
program" if you do not supply a file-spec and do not have
a program currently in memory.
- When you specify a file-spec with the RUN command,
VAX BASIC brings the program into memory and then executes it. You
do not have to bring a program into memory with the OLD command in
order to run it. The RUN command executes just as if the program had
been brought into memory with the OLD command.
- If your program calls a subprogram, the subprogram must be compiled
and placed in memory with the LOAD command. If your program tries to
call a subprogram that has not been compiled and loaded, VAX BASIC
signals an error.
- The RUN command does not create an object module file or a list
file.
- When VAX BASIC encounters a STOP statement in the program, the
program stops executing and control passes to the VAX BASIC Environment
immediate mode.
- Any VAX BASIC statement that does not require the creation of
new storage can be entered in immediate mode to debug the program. You
cannot create new variables in immediate mode.
- Enter the CONTINUE command to resume program execution.
- The RUN command uses whatever qualifiers have been set, with the
exception of those that have no effect on a program running in the VAX
BASIC Environment. These qualifiers are as follows:
NOCROSS
NODEBUG
NOLIST
NOMACHINE
NOOBJECT
These qualifiers are always in effect when you run a program in the
Environment.
- Accessing Shareable Images
- To automatically access shareable image libraries, you must make an
assignment to the logical name BASIC$LIBn. For example:
$ ASSIGN DBAO:[BABCOCK]TESTLIB.OLB BASIC$LIB0
- After you enter a command line, VAX BASIC will automatically
access your library to resolve undefined program symbols.
- If you have more than one library for the OpenVMS Linker to search, you
must assign the first one as BASIC$LIB0, the second one as BASIC$LIB1,
the third as BASIC$LIB2, and so on.
- If you do not number libraries consecutively, the OpenVMS Linker does not
search past the first missing logical name.
- As long as routines are contained in shareable images in libraries,
they are not required to be written in VAX BASIC to
be accessed with the RUN command.
- VAX BASIC provides no default file specification for user-supplied
shareable image libraries; the current default device and
the directory are used.
- The RUN command does not support data sharing with shareable images, for
example, by way of a MAP statement. The program must execute outside
the VAX BASIC Environment to share data.
- After all possible shareable image libraries have been accessed,
VAX BASIC will subsequently search the default library SYS$LIBRARY:.OLB with
the logical name IMAGELIB to resolve any additional undefined program
symbols.
Example
RUN PROG1
PROG1 06-OCT-1999 13:52
1
3
6
10
Ready
RUNNH PROG1
1
3
6
10
Ready
|
SAVE
The SAVE command writes the VAX BASIC source program currently in
memory to a file on the default or specified device.
Format
Syntax Rules
None
Remarks
- If you do not supply a file-spec, VAX BASIC saves the
file with the name of the program currently in memory and the .BAS
default file type.
- If you specify only the file name, VAX BASIC saves the program
with the default file type in the current default directory.
- When you enter the SAVE command, VAX BASIC writes a new version
of the program.
- VAX BASIC stores the sorted program in ascending line number
order.
- You can store the program on a specified device. For example:
VAX BASIC saves the file NEWTEST.PRO on disk DUA1:.
Example
SAVE PROG_SAMP.BAS
%BASIC-I-FILEWRITE, PROG_SAMP written to file:
USER$$DISK[BASICUSER]PROG_SAMP.BAS;2
|
SCALE
The SCALE command allows you to control accumulated round-off errors by
multiplying numeric values by 10 raised to the scale factor before
storing them.
Format
Syntax Rules
Int-const specifies the power of 10 you want to use as the
scaling factor. Int-const must be an integer from 0 to 6 or
VAX BASIC signals the error "Illegal argument for
command."
Remarks
- SCALE with no argument causes VAX BASIC to signal the error
"Illegal argument for command."
- SCALE affects only values of the data type DOUBLE.
- VAX BASIC multiplies values using the scale factor you specify.
For example, the value 2.488888 is rounded as shown in Table 2-1.
Because the constant value 2.488888 is stored as a SINGLE precision
number, it is rounded to 2.48889. When scaling is used, the value is
multiplied by the scale factor and then converted to an integer. For
example, the value 2.48 in Table 2-1 is converted to the integer
248. This number is stored internally as 248.0 in SINGLE precision
format.
Example
SCRATCH
The SCRATCH command clears any program currently in memory, removes any
object files loaded with the LOAD command, and resets the program name
to NONAME.
Format
Syntax Rules
None
Remarks
None
Example
SEQUENCE
The SEQUENCE command causes VAX BASIC to automatically generate
line numbers for your program text. VAX BASIC supplies line numbers
for your text until you end the procedure or reach the maximum line
number of 32767.
Format
Syntax Rules
- Line-num specifies the line number where sequencing begins.
- Int-const specifies the line number increment for your
program. If you do not specify an increment, VAX BASIC defaults to
the int-const specified in the last SEQUENCE command; if there
is no previous SEQUENCE command, the default is 10.
Remarks
- You cannot specify the SEQUENCE command on programs that do not
contain line numbers.
- If you do not specify a line-num, the VAX BASIC
default is the last line inserted by a SEQUENCE command; if there is no
previous SEQUENCE command, the default is line number 100.
- If you specify a line-num that already contains a
statement, or if the sequencing operation generates a line number that
already contains a statement, VAX BASIC signals "Attempt to
sequence over existing statement," and returns to normal input
mode.
- Enter your program text in response to the line number prompt;
pressing Return ends each line and causes VAX BASIC to generate a
new line number.
- If you press Ctrl/Z in response to the line number prompt,
VAX BASIC terminates the sequencing operation and prompts for
another command.
- When the maximum line number of 32767 is reached, VAX BASIC
terminates the sequencing process and returns to normal input mode.
- VAX BASIC does not check syntax during the sequencing process.
Example
SEQUENCE 100,10
100 INPUT "Enter a numeric value";A%
110 IF A% = 20
|
In this example, the command SEQUENCE 100,10 causes VAX BASIC to
automatically generate line numbers into the program text, beginning
with the line number 100 and incrementing each line by 10.