HP OpenVMS Systems

BASIC
Content starts here

Compaq BASIC for OpenVMS
Alpha and VAX Systems
User Manual


Previous Contents Index

2.5.1 Entering Comments

VAX BASIC allows you to enter comments into the VAX BASIC Environment by specifying an exclamation point. Any text that follows the exclamation point (!) is treated as a comment. For example:


$ TYPE build_special.com
$ SET VERIFY
$ BASIC



!+
! Set the compilation unit options by uncommenting
! the appropriate ones
!-
!SET LIST
SET WORD
SET DEBUG
!+
! Get the source module.
!-
OLD SPECIAL
!+
! Compile it.
!-
COMPILE
!+
! All done.
!-
EXIT

2.5.2 Entering DCL Commands

You can enter DCL commands while in the VAX BASIC Environment. To do so, precede each DCL command with a dollar sign ($). VAX BASIC passes the command to DCL for execution. The program currently in memory does not change.

VAX BASIC starts a subprocess to execute the command, and the command executes in the context of that subprocess. This can sometimes produce unexpected results. For example, entering the SET DEFAULT command sets the default for the subprocess but not for the process in which VAX BASIC executes. The newly set default exists only until control returns to VAX BASIC.

2.5.3 APPEND Command

The APPEND command merges a VAX BASIC source program with the program currently in memory. The program in memory must be a VAX BASIC source program that has been placed in memory with the OLD command or entered in the Environment. The program must also contain at least one line number.

If both programs contain a line with the same number, the appended program line replaces the current program line.

If you type APPEND without specifying a file name, VAX BASIC prompts with:


Append file name--

You should respond with a file name. If you respond by pressing Return, VAX BASIC searches for a file called NONAME with the default file type of .BAS. If the compiler cannot find the file, it signals an error.

The APPEND command does not change the name of the program in memory.

2.5.4 ASSIGN Command

The ASSIGN command equates a logical name to a complete file specification, a device, or another logical name.

If the logical name translates to a device name and is used in place of a device name in a file specification, end the equivalence name with a colon.

The following example uses the ASSIGN command to make the system HELP library available from within VAX BASIC:


Ready

ASSIGN SYS$HELP:HELPLIB HLP$LIBRARY

The ASSIGN command does not support search lists. To assign a logical name to a search list from within the Environment, use the system command to execute the DCL command ASSIGN with the /JOB qualifier. For example:


$ ASSIGN/JOB DUA0:[MR.X],DUA0:[MR.Y] TWO$DIRECTORIES:

2.5.5 COMPILE Command

When compiling a program in the VAX BASIC Environment, there are three levels at which you can specify options for the compiler:

  • Accept the defaults of the VAX BASIC Environment as options
  • Specify options with qualifiers to the COMPILE or SET command
  • Specify options in the source program with the OPTION statement

The COMPILE command creates an object module from a source program in memory. You can control the compilation of your program with the COMPILE command and its qualifiers. These qualifiers duplicate many of the qualifiers available to the DCL command BASIC. You can abbreviate all COMPILE qualifiers to four letters. For example, you can compile a program currently in memory and specify the creation of a listing file:


COMPILE/LIST

The following two commands both specify that a listing file is created. Note that the SET command sets a particular default until you leave the VAX BASIC Environment or until you specify a different default for that value, and the qualifiers to the COMPILE command set the defaults only for that particular compilation.


SET/LIST

COMPILE/LIST

If you do not specify any qualifiers with the SET command, VAX BASIC resets the defaults to the values that were in effect when you entered the VAX BASIC Environment.

The qualifiers to the COMPILE command are shown in the following list. Note that you can also use these qualifiers with the SET command to establish compiler options. The qualifiers are described fully in the Compaq BASIC for OpenVMS Alpha and VAX Systems Reference Manual.

  • The /[NO]ANSI_STANDARD qualifier instructs VAX BASIC to compile the program according to ANSI Minimal BASIC rules and to flag statements that do not conform to the ANSI Minimal BASIC standard. The /ANALYSIS_DATA qualifier cannot be in effect when you compile with the /ANSI_STANDARD qualifier.
    The default is /NOANSI_STANDARD.
  • The /[NO]AUDIT qualifier instructs VAX BASIC to include a history entry in the CDD/Repository database when a CDD/Repository definition is extracted.
    The default is /NOAUDIT.
  • The /[NO]BOUNDS qualifier instructs VAX BASIC to perform range checks on array subscripts. This qualifier checks that all array references are to addresses within the array boundaries.
    The default is /BOUNDS.
  • The /BYTE qualifier specifies that integers not explicitly typed with a data type keyword use 8 bits of storage, which lets you use integer values from -128 to 127.
    The default is /INTEGER_SIZE=LONG.
    The /BYTE qualifier is a declining feature. Instead, /INTEGER_SIZE=BYTE is recommended.
  • The /[NO]CROSS_REFERENCE[=[NO]KEYWORDS] qualifier instructs VAX BASIC to generate a cross-reference listing. If you specify KEYWORDS, VAX BASIC provides a cross-reference list of its keywords. If you specify /CROSS_REFERENCE, the default is /CROSS_REFERENCE=NOKEYWORDS.
    The default is /NOCROSS_REFERENCE.
  • The /[NO]DEBUG qualifier provides the debugger with local symbol definitions for program variables, constants, line numbers, and labels. If you make changes to a program within the Environment, you must first save or replace the program before attempting to compile the program with the /DEBUG qualifier; otherwise, VAX BASIC signals the error "Unsaved changes, no source line debugging available."
    The default is /DEBUG=(TRACEBACK,NOSYMBOLS).
  • The /DECIMAL_SIZE qualifier specifies the default size and precision for all DECIMAL data not explicitly assigned size and precision in the program. You specify the total number of digits (d) and the number of digits to the right of the decimal point (s). VAX BASIC signals the error "Decimal error or overflow" (ERR=181) when DECIMAL values are outside the range specified with this qualifier.
    The default is /DECIMAL_SIZE=(15,2).
  • The /DOUBLE qualifier specifies that floating-point data use 64 bits of storage in D_float format, which lets you use floating-point values in the range 2.9 * 10-39 to 1.7 * 1038 and with up to 16 digits of precision.
    The default is /REAL_SIZE=SINGLE.
    The /DOUBLE qualifier is a declining feature. Instead, /REAL_SIZE=DOUBLE is recommended.
  • The /[NO]FLAG[=( [NO]AXPCOMPATIBILITY,
    [NO]BP2COMPATIBILITY,[NO]DECLINING)]
    qualifier instructs VAX BASIC to issue informational messages when your program includes statements that are not compatible with the features you specify. You can specify a flag for compatibility with Alpha BASIC (AXPCOMPATIBILITY), BASIC-PLUS-2 (BP2COMPATIBILITY), and declining VAX BASIC language features (DECLINING).
    The default is /NOFLAG.
  • The /GFLOAT qualifier specifies that floating-point data use 64 bits of storage in G_float format, which lets you use floating-point values in the range 5.6 * 10-308 to 9.0 * 10309 and with up to 15 digits of precision.
    The default is /REAL_SIZE=SINGLE.
    The /GFLOAT qualifier is a declining feature. Instead, /REAL_SIZE=GFLOAT is recommended.
  • The /HFLOAT qualifier specifies that floating-point data use 128 bits of storage in H_float format, which lets you use floating-point values in the range 8.4 * 10-4933 to 5.9 * 104933 and with up to 33 digits of precision.
    The default is /REAL_SIZE=SINGLE.
    The /HFLOAT qualifier is a declining feature. Instead, /REAL_SIZE=HFLOAT is recommended.
  • The /[NO]LINES qualifier enables the executing program to report the line number of statements causing errors and to use the RESUME statement without specifying a line number.
    The default is /LINES.
  • The /[NO]LIST qualifier creates a program listing with a default file type of .LIS.
    The default is /NOLIST.
  • The /LONG qualifier specifies that untyped integers use 32 bits of storage, which lets you use integer values from -2147483648 to 2147483647.
    The default is /INTEGER_SIZE=LONG.
    The /LONG qualifier is a declining feature. Instead, /INTEGER_SIZE=LONG is recommended.
  • The /[NO]MACHINE_CODE qualifier includes the compiler-generated assembly code listing.
    The default is /NOMACHINE_CODE.
  • The /[NO]OBJECT qualifier generates a linkable object module. This object module has the same file name as the VAX BASIC source program and a default file type of .OBJ.
    The default is /OBJECT.
  • The /[NO]OVERFLOW[=([NO]INTEGER,[NO]DECIMAL)] qualifier enables the detection of arithmetic overflow on integer or packed decimal data. If you do not supply a value, OVERFLOW affects both data types.
    The default is /OVERFLOW=(INTEGER,DECIMAL).
  • The /[NO]ROUND qualifier specifies whether VAX BASIC rounds or truncates packed decimal numbers.
    The default is /NOROUND.
  • The /[NO]SETUP qualifier causes VAX BASIC to optimize the executable image by omitting certain calls to the Run-Time Library at the start and end of each program unit. Note that variables are not initialized when /NOSETUP is in effect.
    The default is /SETUP.
  • The /[NO]SHOW qualifier allows you to specify what is included in the listing file. For a list of items you can include in the listing file, see the Compaq BASIC for OpenVMS Alpha and VAX Systems Reference Manual.
    The default is /SHOW.
  • The /SINGLE qualifier specifies that floating-point data use 32 bits of storage, which lets you use floating-point values in the range 2.9 * 10-39 to 1.7 * 1038 and with up to 6 digits of precision.
    The default is /REAL_SIZE=SINGLE.
    The /SINGLE qualifier is a declining feature. Instead, /REAL_SIZE=SINGLE is recommended.
  • The /[NO]SYNTAX_CHECK qualifier enables line-by-line syntax checking. Because VAX BASIC automatically performs syntax checking when you compile a program, you normally use /SYNTAX_CHECK with the SET command to enable line-by-line syntax checking while you are typing program lines.
    The default is /NOSYNTAX_CHECK.
  • The /[NO]TRACEBACK qualifier provides line numbers for the debugger and error reporter so they can translate virtual addresses into source program module names and line numbers.
    The default is /TRACEBACK.
  • The /TYPE_DEFAULT qualifier allows you to specify the default data type for all data not explicitly typed in your program. See the Compaq BASIC for OpenVMS Alpha and VAX Systems Reference Manual for a list of data types you can include.
    The default is /TYPE_DEFAULT=REAL.
  • The /VARIANT=value qualifier provides a value to be tested in conditional compilations.
    The default is /VARIANT=0.
  • The /[NO]WARNINGS[=[NO]WARNINGS,[NO]INFORMATIONALS] qualifier tells VAX BASIC whether to display warning or informational error messages. The /NOWARNINGS qualifier instructs VAX BASIC to not display any informational or warning errors.
    The default is /WARNINGS=WARNINGS,INFORMATIONALS.
  • The /WORD qualifier specifies that all integer data not explicitly typed use 16 bits of storage, which lets you use integer values from -32768 to 32767.
    The default is /INTEGER_SIZE=LONG.
    The /WORD qualifier is a declining feature. Instead, /INTEGER_SIZE=WORD is recommended.

If you use these qualifiers with the COMPILE command, the VAX BASIC Environment default values remain the same, but your program is compiled using the qualifiers and values you specify. When you use these qualifiers with the SET command, you set the defaults while you are in the VAX BASIC Environment. You can also set compiler options from inside the source program by using the OPTION statement. See the Compaq BASIC for OpenVMS Alpha and VAX Systems Reference Manual for more information about the OPTION statement.

If you specify the /DIAGNOSTICS qualifier or the /ANALYSIS_DATA qualifier with the BASIC command, then make changes to a program and attempt to compile the program before saving or replacing it, VAX BASIC signals the error "Unsaved changes, no diagnostics file produced" or "Unsaved changes, no analysis file produced." You must save or replace the program before you compile it to generate a diagnostics or data analysis file.

2.5.6 CONTINUE Command

The CONTINUE command resumes program execution after VAX BASIC encounters a STOP statement or a Ctrl/C. After a STOP statement or a Ctrl/C is encountered, you can enter immediate mode statements to display or change program variables. Enter CONTINUE to resume execution with the new values.

2.5.7 DELETE Command

The DELETE command removes a specified line or lines from the source program currently in memory. If you separate line numbers with commas, VAX BASIC deletes only the specified program lines. If you separate line numbers with a hyphen (-), VAX BASIC deletes the specified program lines and all program lines between them. For example:

DELETE 10 Removes line 10 from the program
DELETE 50, 100 Removes lines 50 and 100 from the program
DELETE 50, 100-190 Removes line 50 and lines 100 to 190 from the program

If you do not specify a line number, the DELETE command is ignored.

2.5.8 EDIT Command

The EDIT command replaces text in the current program with text you supply in the command. If you type EDIT with no argument, VAX BASIC invokes a text editor and reads the current program into the editor's buffer.

Table 2-2 shows examples of editing in line mode.

Table 2-2 Examples of Editing in Line Mode
EDIT 100 /LEFT$/RIGHT$/ Replaces the first occurrence of LEFT$ with RIGHT$ on line 100.
EDIT Invokes the default editor and reads the current program into the editor's buffer.
EDIT 2000 Lists line 2000 (line 2000 becomes the default EDIT line).
EDIT 30 /LEFT$/RIGHT$/,3 Starts the search on the third text line of program line 30 and replaces the first occurrence of LEFT$ with RIGHT$.
EDIT 300/LEFT$//2 Removes the second occurrence of the string LEFT$ from line 300. Note that you must specify delimiters around the null replacement string; otherwise, the EDIT command replaces the first occurrence of LEFT$ with 2.

Entering EDIT with no argument instructs VAX BASIC to save your program temporarily in a file called BASEDITMP.BAS. The editor is then invoked and you can edit the program. Exiting from the editor causes the changed program to become the current program. VAX BASIC then displays the Ready prompt.

Note

VAX BASIC deletes all versions of BASEDITMP.BAS when control returns from the editor.

VAX BASIC supports the following callable text editors:

  • EDT
  • Text Processing Utility (TPU)
  • Language-Sensitive Editor (LSE)

The default editor for VAX BASIC is EDT. In DCL, you can override this default by defining the logical name BASIC$EDIT. To find out if a system assignment exists, enter the following DCL command:


$ SHOW LOGICAL BASIC$EDIT

The name you assign to BASIC$EDIT must be in the form nnn$EDIT, (nnn represents the acronym for the editor). For example, you can assign LSE to be the default editor with the following command:


$ ASSIGN "LSE$EDIT" BASIC$EDIT

If the translation of BASIC$EDIT does not conform to nnn$EDIT, VAX BASIC creates a temporary file containing your source code and spawns a subprocess. VAX BASIC passes the translation of BASIC$EDIT to the subprocess.

2.5.9 EXIT Command

The EXIT command clears memory and returns control to DCL command level. If you modify a program and enter the EXIT command before you copy it to disk with the SAVE or REPLACE command, VAX BASIC signals "Unsaved change has been made, Ctrl/Z or EXIT to exit." This message warns you that any changes will be lost if you do not save the program. You can then store the program or reenter the EXIT command (or press Ctrl/Z) to exit from VAX BASIC.

2.5.10 HELP Command

The HELP command lets you display the contents of the VAX BASIC HELP library. A list of commands and language topics for which there is help available is displayed. You are prompted to name a command or topic with the following prompt:


Topic?

To obtain help on the Environment commands, enter COMMANDS at the Topic? prompt. A list of commands is displayed on your terminal followed by the prompt COMMANDS Subtopic?. When you type a command name in response to this prompt, the HELP facility displays the following:

  • An explanation of the command's purpose
  • An example of its use
  • A list of any further subtopics available

You can also display help text for VAX BASIC errors. The help texts for the VAX BASIC error messages are grouped under two categories: compile-time errors and run-time errors. A run-time error refers to any error that occurs during program execution. All other errors are referred to as compile-time errors. Entering HELP RUN displays a list of the 3- to 9-character error mnemonics for the VAX BASIC list of run-time errors, and entering HELP COMPILE displays a list of the 3- to 9-character compile-time error mnemonics.

For example, if your program invokes a user-defined DEF function with a null argument, this causes VAX BASIC to signal the following error message:


%BASIC-E-ACTARGMUS, actual argument must be specified

You display the help text by entering the following command:


HELP COMPILE ACTARGMUS

The following text displays on your screen:


ACTARGMUS

     ERROR - A DEF function reference contains a null argument,  for
     example FNA(1,,2). Specify all arguments when referencing a DEF
     function.

You can access run-time errors with either the mnemonic or the error number. You specify the error number with the letters "ERR" followed by the error number. For example, you can display the HELP text for the end-of-file error by using the mnemonic as follows:


HELP RUN ENDFILDEV

If you know only the error number, enter the following:


HELP RUN ERR11

VAX BASIC displays the appropriate mnemonic for that error.

2.5.11 IDENTIFY Command

The IDENTIFY command prints a header containing the VAX BASIC compiler name and version number. For example:


IDENTIFY

VAX BASIC Vn.n

Ready

2.5.12 LIST and LISTNH Commands

The LIST and LISTNH commands display a specified line or lines. If you type LIST or LISTNH without specifying line numbers, VAX BASIC displays a copy of the source program currently in memory, in ascending line number order.

The LIST command prints a header displaying the program name and the current time and date before displaying the specified lines. The LISTNH command suppresses the header information and prints the specified lines only. For example:

LIST 10 Displays header information, then displays line 10
LISTNH 50, 100 Displays lines 50 and 100
LIST 50, 90, 100-190 Displays header information, then displays lines 50, 90, and 100 to 190

2.5.13 LOAD Command

The LOAD command makes an object module available for execution with the RUN command. You can only load object files created by VAX BASIC.

The LOAD command accepts multiple device, directory, and file specifications. The LOAD command deletes all previously loaded object files; therefore, to load several files at the same time, you must separate the file specifications with a plus sign (+). Multiple file specifications separated with commas cause each file to be loaded separately, thereby deleting the previously loaded file.

If you do not specify any file specification, the LOAD command erases any previously loaded object files.


LOAD OLD1 + OLD2 + OLD3

Ready

RUN

The previous example loads the files OLD1.OBJ, OLD2.OBJ, and OLD3.OBJ for execution. These object files are not linked with the current program or executed until you issue the RUN command. Therefore, run-time errors in the loaded modules are not detected until you execute the program.

Each device and directory specification applies to all following file specifications until you specify a new directory or device. For example:


LOAD DUA1:[SMITH]PROG3+[JONES]PROG4+DUA2:PROG5

This command loads three object files:

  • PROG3 from the directory SMITH on the device DUA1:
  • PROG4 from the directory JONES on DUA1:
  • PROG5 from the directory JONES on DUA2:


Previous Next Contents Index