# Compaq BASIC for OpenVMS
Alpha and VAX Systems
Reference Manual

Previous | Contents | Index

# Appendix B
BASIC Keywords

The following is a list of the BASIC keywords. Most of the keywords are reserved; unreserved keywords are marked with a dagger (+).

> %ABORT
> %CDD+
> %CROSS
> %DEFINE
> %ELSE
> %END
> %FROM
> %IDENT
> %IF
> %INCLUDE
> %LET
> %LIBRARY
> %LIST
> %NOCROSS
> %NOLIST
> %PAGE
> %PRINT
> %SBTTL
> %THEN
> %TITLE
> %UNDEFINE
> %VARIANT
> ABORT
> ABS
> ABS%
> ACCESS
> ACCESS%
> ACTIVATE
> ACTIVE
> ALIGNED
> ALLOW
> ALTERNATE
> AND
> ANGLE+
> ANY
> APPEND
> AREA+
> AS
> ASC
> ASCENDING
> ASCII
> ASK
> AT+
> ATN
> ATN2
> BACK
> BASE
> BASIC
> BEL
> BINARY
> BIT
> BLOCK
> BLOCKSIZE
> BS
> BUCKETSIZE
> BUFFER
> BUFSIZ
> BY
> BYTE
> CALL
> CASE
> CAUSE
> CCPOS
> CHAIN
> CHANGE
> CHANGES
> CHECKING
> CHOICE+
> CHR$
> CLEAR
> CLIP+
> CLK$
> CLOSE
> CLUSTERSIZE
> COLOR+
> COM
> COMMON
> COMP%
> CON
> CONNECT
> CONSTANT
> CONTIGUOUS
> CONTINUE
> COS
> COT
> COUNT
> CR
> CTRLC
> CVTF$
> CVT$F
> CVT$$
> CVT$%
> CVT%$
> DAT
> DAT$
> DATA
> DATE$
> DEACTIVATE
> DECIMAL
> DECLARE
> DEF
> DEF*
> DEFAULTNAME
> DEL
> DELETE
> DESC
> DESCENDING
> DET
> DEVICE
> DIF$
> DIM
> DIMENSION
> DOUBLE
> DOUBLEBUF
> DRAW
> DUPLICATES
> DYNAMIC
> ECHO
> EDIT$
> ELSE
> END
> EQ
> EQV
> ERL
> ERN$
> ERR
> ERROR
> ERT$
> ESC
> EXIT
> EXP
> EXPAND+
> EXPLICIT
> EXTEND
> EXTENDSIZE
> EXTERNAL
> FF
> FIELD
> FILE
> FILESIZE
> FILL
> FILL$
> FILL%
> FIND
> FIX
> FIXED
> FLUSH
> FNAME$
> FNEND
> FNEXIT
> FONT+
> FOR
> FORMAT$
> FORTRAN
> FREE
> FROM
> FSP$
> FSS$
> FUNCTION
> FUNCTIONEND
> FUNCTIONEXIT
> GE
> GET
> GETRFA
> GFLOAT
> GO
> GOBACK
> GOSUB
> GOTO
> GRAPH
> GRAPHICS+
> GROUP
> GT
> HANDLE
> HANDLER
> HEIGHT+
> HFLOAT
> HT
> IDN
> IF
> IFEND
> IFMORE
> IMAGE
> IMP
> IN+
> INACTIVE
> INDEX+
> INDEXED
> INFORMATIONAL
> INITIAL
> INKEY$
> INPUT
> INSTR
> INT
> INTEGER
> INV
> INVALID
> ITERATE
> JSB
> JUSTIFY+
> KEY
> KILL
> LBOUND
> LEFT
> LEFT$
> LEN
> LET
> LF
> LINE
> LINES+
> LINO
> LINPUT
> LIST
> LOC
> LOCKED
> LOG
> LOG10
> LONG
> LSET
> MAG
> MAGTAPE
> MAP
> MAR
> MAR%
> MARGIN
> MAT
> MAX
> METAFILE+
> MID
> MID$
> MIN
> MIX+
> MOD
> MOD%
> MODE
> MODIFY
> MOVE
> MULTIPOINT+
> NAME
> NEXT
> NO+
> NOCHANGES
> NODATA
> NODUPLICATES
> NOECHO
> NOEXTEND
> NOMARGIN
> NONE
> NOPAGE
> NOREWIND
> NOSPAN
> NOT
> NUL$
> NUM
> NUM$
> NUM1$
> NUM2
> NX
> NXEQ
> OF
> ON
> ONECHR
> ONERROR
> OPEN
> OPTION
> OPTIONAL
> OR
> ORGANIZATION
> OTHERWISE
> OUTPUT
> OVERFLOW
> PAGE
> PATH+
> PEEK
> PI
> PICTURE
> PLACE$
> PLOT
> POINT+
> POINTS+
> POS
> POS%
> PPS%
> PRIMARY
> PRINT
> PRIORITY+
> PROD$
> PROGRAM
> PROMPT+
> PUT
> QUAD
> QUO$
> RAD$
> RANDOM
> RANDOMIZE
> RANGE+
> RCTRLC
> RCTRLO
> READ
> REAL
> RECORD
> RECORDSIZE
> RECORDTYPE
> RECOUNT
> REF
> REGARDLESS
> RELATIVE
> REM
> REMAP
> RESET
> RESTORE
> RESUME
> RETRY
> RETURN
> RFA
> RIGHT
> RIGHT$
> RMSSTATUS
> RND
> ROTATE
> ROUNDING
> RSET
> SCALE
> SCRATCH
> SEG$
> SELECT
> SEQUENTIAL
> SET
> SETUP
> SEVERE
> SFLOAT
> SGN
> SHEAR
> SHIFT
> SI
> SIN
> SINGLE
> SIZE
> SLEEP
> SO
> SP
> SPACE+
> SPACE$
> SPAN
> SPEC%
> SQR
> SQRT
> STATUS
> STEP
> STOP
> STR$
> STREAM
> STRING
> STRING$
> STYLE+
> SUB
> SUBEND
> SUBEXIT
> SUBSCRIPT
> SUM$
> SWAP%
> SYS
> TAB
> TAN
> TEMPORARY
> TERMINAL
> TEXT+
> TFLOAT
> THEN
> TIM
> TIME
> TIME$
> TO
> TRAN+
> TRANSFORM
> TRANSFORMATION+
> TRM$
> TRN
> TYP
> TYPE
> TYPE$
> UBOUND
> UNALIGNED
> UNDEFINED
> UNIT+
> UNLESS
> UNLOCK
> UNTIL
> UPDATE
> USAGE$
> USEROPEN
> USING
> USR$
> VAL
> VAL%
> VALUE
> VARIABLE
> VARIANT
> VFC
> VIEWPORT+
> VIRTUAL
> VPS%
> VT
> WAIT
> WARNING
> WHEN
> WHILE
> WINDOW+)
> WINDOWSIZE
> WITH+
> WORD
> WRITE
> XFLOAT
> XLATE
> XLATE$
> XOR
> ZER

Note #### + Unreserved keyword #### + Unreserved keyword

# Appendix C
Differences Between Alpha BASIC and VAX BASIC

Compaq BASIC for OpenVMS Alpha systems (hereafter referred to as Alpha BASIC) is based on and compatible with Compaq BASIC for OpenVMS VAX systems (hereafter referred to as (VAX BASIC).

Alpha BASIC supports most of the VAX BASIC features. This appendix describes the differences between Alpha BASIC and VAX BASIC.

# C.1 Feature Differences

This section describes the following:

- VAX BASIC features that are not available in Alpha BASIC
- Alpha BASIC features that are not available in VAX BASIC

## C.1.1 VAX BASIC Features Not Available in Alpha BASIC

Table C-1 describes the VAX BASIC features not available in Alpha BASIC. There are no plans for Alpha BASIC to support these features.

Table C-1 VAX BASIC Features Not Available in Alpha BASIC
Features | Comments
--- | ---
/[NO]ANSI_STANDARD | Enforces the ANSI Minimal BASIC standard.
VAX BASIC Environment | The VAX BASIC Environment provides features specific to BASIC for program development. The RUN command and immediate mode are not supported.
/[NO]SYNTAX_CHECK | Specifies syntax checking after every entered line.
/[NO]FLAG=[BP2COMPATIBILITY] | Notifies VAX BASIC users of VAX BASIC features that are not compatible with PDP--11 BASIC/PLUS2.
/[NO]FLAG=[AXPCOMPATIBILITY] | Notifies VAX BASIC users of VAX BASIC features that are not supported by Alpha BASIC.
Graphics statements | Graphics statements are not supported.
HFLOAT data type | Specifies floating-point format for floating-point data. Additionally, the HFLOAT argument to the REAL built-in function is not supported.
/[NO]DESIGN | There is no support for the Program Design Facility (PDF). The compiler does not attempt to compile a program when /DESIGN is specified.

## C.1.2 Alpha BASIC Features Not Available in VAX BASIC

Table C-2 describes Alpha BASIC command line qualifiers not available in VAX BASIC. For detailed information about all the BASIC qualifiers, see the Compaq BASIC for OpenVMS Alpha and VAX Systems User Manual.

Table C-2 Alpha BASIC Qualifiers Not Available in VAX BASIC
Qualifier | Comments
--- | ---
/INTEGER_SIZE=QUAD | Allows you to specify that integers should be quadwords (that is, 64 bits in size).
/OPTIMIZE=LEVEL= n | Controls the level of optimization done by the compiler. (/OPTIMIZE without the LEVEL is available in VAX BASIC; see Section C.2.1.)
/REAL_SIZE={SFLOAT | TFLOAT | XFLOAT} | Allows you to specify one of the IEEE floating-point data types, SFLOAT, TFLOAT, or XFLOAT.
/SEPARATE_COMPILATION | Controls whether an individual compilation unit becomes a separate module in an object file.
/SYNCHRONOUS_EXCEPTIONS | Controls whether or not the compiler emits additional code to emulate VAX BASIC exception behavior.
/WARNINGS=ALIGNMENT | Instructs the compiler to flag all occurrences of non-naturally aligned RECORD fields, variables within COMMONs and MAPs, and RECORD arrays.

# C.2 Behavior Differences

This section describes the behavior differences between Alpha BASIC and VAX BASIC.

## C.2.1 Optimization

In both Alpha BASIC and VAX BASIC, the /[NO]OPTIMIZE qualifier controls whether optimization is turned on or off, and for both the default is /OPTIMIZE (unless /DEBUG is specified).

The difference is that Alpha BASIC allows you to specify which of four levels of optimization the compiler should perform. The default is /OPTIMIZE=LEVEL=4 (full optimization). In VAX BASIC, you cannot specify a level of optimization. For more information, see the section on BASIC command qualifiers in the Compaq BASIC for OpenVMS Alpha and VAX Systems User Manual.

## C.2.2 Data Types

The following data types are discussed in this section:

- QUAD, SFLOAT, TFLOAT, and XFLOAT
- Implicit use of HFLOAT
- Double
- HFLOAT and HFLOAT Complex in Oracle CDD/Repository

### C.2.2.1 QUAD, SFLOAT, TFLOAT, and XFLOAT

Alpha BASIC has four data types not available in VAX BASIC:

- QUAD allows you to specify a size of 64 bits (quadword) for integers.
- SFLOAT, TFLOAT, and XFLOAT are IEEE floating-point data types requiring Version 7.1 or higher of the OpenVMS Alpha operating system.

These four data types allow the Alpha BASIC user to take advantage of the 64-bit Alpha architecture.

### C.2.2.2 Implicit Use of the HFLOAT Data Type

VAX BASIC performs some intermediate calculations in the HFLOAT data type, even if the source code does not explicitly specify its use. This generally occurs when mixed data type operations are performed between large DECIMAL items and floating-point items. For more information about VAX BASIC behavior, see Section 1.6.1.1.

Alpha BASIC performs these operations in GFLOAT. As a result, some loss of precision is possible. Alpha BASIC issues the following compile-time warning message if source code is encountered that results in this difference:

    OPEPERGFL, operation performed in GFLOAT, loss of precision possible

### C.2.2.3 Double Data Type

The Alpha hardware does not completely support the D-floating data type. Alpha BASIC performs BASIC DOUBLE operations (+, -, and so on) in G-floating (consistent with other languages on OpenVMS Alpha systems). As a result, the operations lose three bits of precision.

Alpha BASIC performs mixed operations between GFLOAT and DOUBLE in GFLOAT, not HFLOAT. VAX BASIC performs mixed operations between GFLOAT and DOUBLE in HFLOAT.

Conversions between the human world of decimal numbers and the binary world of computers cause rounding errors. For example, .1 (1/10) cannot be represented exactly in either D_floating or G_floating data type. It must be rounded. Because the D_floating and G_floating representations provide differing amounts of precision, the rounding error may be slightly different. As a result, the D_floating and G_floating representations of the same decimal number are not always the same when converted back to decimal.

### C.2.2.4 HFLOAT Data Type and HFLOAT COMPLEX Data Type in Oracle CDD/Repository

Alpha BASIC does not support HFLOAT. Neither Alpha BASIC nor VAX BASIC support the HFLOAT COMPLEX data type. The following sections discuss the translations that occur when reading records from Oracle CDD/Repository.

HFLOAT Data Type

In Alpha BASIC, HFLOAT data types generate a GROUP using the name of the HFLOAT item specified in Oracle CDD/Repository. The GROUP contains a single 16 byte string item. Because HFLOAT is not supported, the compiler generates an informational message similiar to those caused by other unsupported data types.

Example C_1 is an Alpha BASIC example. Example C-2 is a VAX BASIC example.

Example C-1 Alpha BASIC HFLOAT Translation

    GROUP MY_H_REAL
        STRING STRING_VALUE = 16
    END GROUP

Example C-2 VAX BASIC HFLOAT Translation

    HFLOAT MY_H_REAL

HFLOAT COMPLEX Data Type

In Alpha BASIC, the Oracle CDD/Repository data type HFLOAT COMPLEX maps to a GROUP of two 16-byte static strings. Example C-3 shows Oracle CDD/Repository output on Alpha BASIC.

Example C-3 Oracle CDD/Repository HFLOAT COMPLEX Data Type with Alpha BASIC

    GROUP MY_H_COMPLEX
        STRING HFLOAT_R_VALUE = 16
        STRING HFLOAT_I_VALUE = 16
    END GROUP

Example C-4 shows Oracle CDD/Repository output on VAX BASIC.

Example C-4 Oracle CDD/Repository HFLOAT COMPLEX Data Type with VAX BASIC

    GROUP MY_H_COMPLEX
        HFLOAT HFLOAT_R_VALUE
        HFLOAT HFLOAT_I_VALUE
    END GROUP

## C.2.3 Array Parameters

The following are differences in the way Alpha BASIC and VAX BASIC handle array parameters:

- Both Alpha BASIC and VAX BASIC perform parameter checking when an entire array is passed to a subprogram or function. When the array that was passed does not match the array that is expected by the subprogram or function, the compiler issues the error message "Arguments don't match." VAX BASIC performs this check each time the array is referenced. Alpha BASIC performs this check once at the start of the subprogram or function.
  Alpha BASIC processes array parameters more efficiently. The following differences exist between Alpha BASIC and VAX BASIC in the way each processes array parameters:
  - In Alpha BASIC, if a subprogram or function declares an array in its parameter list, the calling program must pass an array when calling the subprogram or function. If this is not done, an unexpected failure can occur. For example, passing a null parameter instead of an array causes a memory management violation and the program fails. In VAX BASIC, it is valid for the program to pass a null parameter if the array is not accessed in the subprogram.
  - In Alpha BASIC, the subprogram cannot trap the "Arguments don't match" error. The error is signaled, but can only be trapped by the calling program.
- When passing an entire array by descriptor, VAX BASIC creates a
  DSC$K_CLASS_A descriptor; Alpha BASIC creates a DSC$K_CLASS_NCA descriptor.
  For most BASIC applications, this is not noticeable because both the calling program and the called subprogram use NCA descriptors. However, a program that relies on individual descriptor fields may have to be modified to work with descriptors produced by Alpha BASIC.
  For more information about DSC$K_CLASS_A and DSC$K_CLASS_NCA descriptors, see the OpenVMS Calling Standard.
- VAX BASIC performs no scale or precision checking when passing entire decimal arrays to a subprogram or function.
  Alpha BASIC subprograms and functions check all decimal arrays received by descriptor to verify that precision, scale factor, and bound information match those of the parameter in the calling program. For example, the following program causes the error "Arguments don't match" when the subprogram test_func starts to execute:

      10 declare decimal(5,2) a(10)
      20 call test_func(a())
      30 print a(1)
      35 end

      40 sub test_func(decimal(10,4) b())
      45 b(1) = 12.12
      50 end sub

- VAX BASIC performs minimal checking when receiving an array of records from a caller. For example, in the following program, VAX BASIC does not check whether the size of the array passed is equal to the size declared in the subprogram.
  Alpha BASIC checks that the size of the array elements are the same and that the number of dimensions match. The following program produces the error "Arguments don't match" when the subprogram test_func starts to execute:

      10 record rec1
          long a
          long b
         end record
         declare rec1 a(10)
         call test_func(a())
         end

      40 sub test_func(rec2 a())
          record rec2
              long x
              long y
              long z
          end record
          a(2)::x = 1
      50  end sub

- VAX BASIC always performs bounds checking on arrays received as descriptor parameters.
  Alpha BASIC does not perform bounds checking on arrays received as descriptor parameters if the /CHECK=NOBOUNDS qualifier is specified. In this way, arrays received as parameters are consistent with all other arrays.

## C.2.4 DEF* Routines

In Alpha BASIC, DEF* routines cannot be called from within DEF routines or WHEN handlers. If such calls are attempted, the following error message is issued:

    %BASIC-E-DEFSNOTALL, DEF* reference not allowed in DEF or handler

Alpha BASIC gives highest precedence to DEF* routines that are called from within an expression. Thus, a DEF* routine call is evaluated first. When the DEF* routine directly modifies the values of variables used within the same expression, this can affect the result of the expression. If the compiler changes the order of a DEF* call in an expression, it issues the following warning message:

    %BASIC-W-DEFEXPCOM, expression with DEF* too complex, moving <name> invocation

You can avoid this by simplifying the expression.

## C.2.5 /LINES Qualifier

In Alpha BASIC, the /LINES qualifier affects only the ERL function and determines whether BASIC line numbers are reported in run-time error messages. The following differences exist in Alpha BASIC:

- /NOLINES is the default.
- You do not have to use /LINES to use the RESUME statement without a target.
- Using /LINES in programs that have line numbers on most lines can negatively affect run-time performance.

## C.2.6 Appending Files at the DCL Command Line

VAX BASIC requires that source files using the plus sign (+) to append source files use line numbers within the files; otherwise, an error message is issued.

Alpha BASIC does not require line numbers in either of the source files. The plus sign is treated as an OpenVMS append operator. Alpha BASIC appends and compiles the separate files as if they were a single source file.

## C.2.7 Unreachable Code Error

Alpha BASIC performs extensive analysis when searching for unreachable code and may report more occurrences than VAX BASIC.

In Alpha BASIC, the compile-time error message for unreachable code, UNREACH, is an informational message. In VAX BASIC, the compile-time error message for unreachable code, INACOFOL, is a warning.

Alpha BASIC checks for DEF functions that are never referenced and issues the informational message "UNCALLED, routine xxxx can never be called."

## C.2.8 Line Numbers

In Alpha BASIC, unlike VAX BASIC, you cannot have duplicate line numbers or line numbers not in ascending numerical order. This restriction applies to single source files or source files concatenated with a plus sign (+) at the DCL command line. Duplicate line numbers or line numbers not in ascending order cause "E" level compilation errors.

VAX BASIC does allow duplicates and lines out of order. Alpha BASIC provides an example TPU command procedure to help work around this difference. It can be used to append source files and sort BASIC line numbers into ascending numerical order from one or more source files.

After installation of Alpha BASIC, the location of the TPU command procedure is:

SYS$COMMON:[SYSHLP.EXAMPLES.BASIC]BASIC$ENV.TPU.

Instructions for its use are in the file.

Note Although there are no known problems, the TPU command procedure has not been thoroughly tested. As a result, it is not supported by Compaq.

Previous | Next | Contents | Index