Compaq BASIC for OpenVMS
Alpha and VAX Systems
Reference Manual


Previous Contents Index


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

  1. Each device and directory specification applies to all following file specifications until you specify a new directory or device.
  2. The LOAD command accepts multiple device, directory, and file specifications.
  3. 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.
  4. VAX BASIC signals an error in the following cases:
    Errors do not change the program currently in memory.
  5. The LOAD command clears all previously loaded object modules from memory.
  6. 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

  1. VAX BASIC signals an error if prog-name exceeds 39 characters.
  2. VAX BASIC signals "error in program name" if you specify a file type.
  3. If you do not specify a prog-name, VAX BASIC prompts with:


    New file name-- 
    

  4. 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.
  5. When you enter the NEW command, the program currently in memory is cleared. Program modules loaded with the LOAD command remain unchanged.

Example


NEW PROG1 


OLD

The OLD command brings a previously created VAX BASIC program into memory.

Format



Syntax Rules

  1. 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.
  2. The default file type is .BAS.

Remarks

  1. If the VAX BASIC compiler cannot find the file you specify, BASIC signals the error "File not found."
  2. 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


OLD CHECK 
Ready 


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

  1. 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.
  2. If you specify a file type, VAX BASIC signals the error "Error in program name."

Remarks

  1. 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.
  2. If you do not specify a prog-name, VAX BASIC renames the program currently in memory NONAME.
  3. 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.
  4. 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

  1. If you do not have write access to the directory containing the original file, VAX BASIC signals an error message.
  2. 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.
  3. 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.
  4. 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

  1. 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.
  2. 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.
  3. 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.
  4. Int-const specifies the numbering increment for the resequencing operation. The default for int-const is 10.

Remarks

  1. You cannot specify the RESEQUENCE command on programs that do not contain line numbers.
  2. 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.
  3. 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.
  4. VAX BASIC sorts the renumbered program in ascending order when the RESEQUENCE command executes.
  5. If the renumbering creates a line number greater than the maximum line number of 32767, VAX BASIC signals an error.
  6. 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.
  7. VAX BASIC signals the error "Undefined line number" in the case of undefined line numbers and does not resequence the program.
  8. VAX BASIC corrects all line numbers for statements that transfer control.
  9. VAX BASIC does not modify the program currently in memory when the RESEQUENCE command generates an error.
  10. 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

  1. Executing a Program
  2. Accessing Shareable Images

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

  1. 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.
  2. If you specify only the file name, VAX BASIC saves the program with the default file type in the current default directory.
  3. When you enter the SAVE command, VAX BASIC writes a new version of the program.
  4. VAX BASIC stores the sorted program in ascending line number order.
  5. You can store the program on a specified device. For example:


    SAVE DUA1:NEWTEST.PRO 
    

    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

  1. SCALE with no argument causes VAX BASIC to signal the error "Illegal argument for command."
  2. SCALE affects only values of the data type DOUBLE.
  3. 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.

Table 2-1 Multiplying a Numeric Value with the SCALE Command
Scale Value Produced for 2.488888
0 2.48889
1 2.4
2 2.48
3 2.488
4 2.4888
5 2.48888
6 2.48889


Example


SCALE 2 


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


SCRATCH 


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

  1. Line-num specifies the line number where sequencing begins.
  2. 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

  1. You cannot specify the SEQUENCE command on programs that do not contain line numbers.
  2. 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.
  3. 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.
  4. 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.
  5. If you press Ctrl/Z in response to the line number prompt, VAX BASIC terminates the sequencing operation and prompts for another command.

  6. When the maximum line number of 32767 is reached, VAX BASIC terminates the sequencing process and returns to normal input mode.
  7. 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.


Previous Next Contents Index