[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP BASIC for OpenVMS
Reference Manual


Previous Contents Index


Appendix B
HP BASIC Keywords

The following is a list of the HP 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 Variations of BASIC

This appendix describes:

C.1 Differences Between I64 BASIC and Alpha BASIC

I64 BASIC supports most of the Alpha BASIC features.

Differences are:

  • On I64 BASIC, the default floating-point format is S_floating, corresponding to the data type keyword SFLOAT. On Alpha BASIC, the default floating-point type is F_floating, corresponding to the data type keyword SINGLE.
  • The Itanium architecture does not support the VAX floating-point data types (FFLOAT, DFLOAT, GFLOAT, and HFLOAT). All uses of these data types are converted to an appropriate IEEE data type before any computation is performed, and then the result is converted back to the original data type. This process might cause rounding errors, and might result in slight differences compared with results obtained using VAX floating-point daata types directly.
  • The /ARCHITECTURE and /OPTIMIZE=TUNE qualifiers on I64 BASIC support the options ITANIUM and MERCED and ignore the various Alpha-specific options.

C.2 Differences Between VAX BASIC and I64 BASIC/Alpha BASIC

C.2.1 VAX BASIC Features Not Available in I64 BASIC/Alpha BASIC

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

Table C-1 VAX BASIC Features Not Available in I64 BASIC / 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 I64 BASIC/Alpha BASIC.
Graphics statements Graphics statements, graphics transformation functions, and the information in Programming with VAX BASIC Graphics is 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.2.2 I64 BASIC/Alpha BASIC Features Not Available in VAX BASIC

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

Table C-2 I64 BASIC / 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.3.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.3 Behavior Differences

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

C.2.3.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 HP BASIC for OpenVMS User Manual.

C.2.3.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.3.2.1 QUAD, SFLOAT, TFLOAT, and XFLOAT

I64 BASIC/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.3.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.

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.3.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.3.2.4 HFLOAT Data Type and HFLOAT COMPLEX Data Type in Oracle CDD/Repository

I64 BASIC/Alpha BASIC does not support HFLOAT. Neither I64 BASIC/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 I64 BASIC/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.

See Example C-1 and Example C-2.

Example C-1 I64 BASIC / 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 I64 BASIC/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 I64 BASIC/Alpha BASIC.

Example C-3 Oracle CDD/Repository HFLOAT COMPLEX Data Type with I64 BASIC / 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.3 Passing Parameters by Value

Both I64 BASIC/Alpha BASIC and VAX BASIC are able to pass actual parameters by value, but only I64 BASIC/Alpha BASIC allow by-value formal parameters.

C.2.3.4 Array Parameters

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

  • Both I64 BASIC/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. I64 BASIC/Alpha BASIC performs this check once at the start of the subprogram or function.
    I64 BASIC/Alpha BASIC processes array parameters more efficiently. The following differences exist between I64 BASIC/Alpha BASIC and VAX BASIC in the way each processes array parameters:
    • In I64 BASIC/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 I64 BASIC/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; I64 BASIC/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 I64 BASIC/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.
    I64 BASIC/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.
    I64 BASIC/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.
    I64 BASIC/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.3.5 DEF* Routines

In I64 BASIC/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

I64 BASIC/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.3.6 /LINES Qualifier

In I64 BASIC/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 I64 BASIC/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.3.7 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.

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

C.2.3.8 Unreachable Code Error

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

In I64 BASIC/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.

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


Previous Next Contents Index