# Compaq BASIC for OpenVMS
Alpha and VAX Systems

# User Manual

Order Number: AA--HY15E--TK

# April 2000

This manual describes how to develop Compaq BASIC programs and use Compaq BASIC features on OpenVMS systems.

Revision/Update Information: This revised manual supersedes the DEC BASIC and VAX BASIC for OpenVMS Systems User's Manual.

Software Version: Compaq BASIC Version 1.4
for OpenVMS Alpha Systems
Compaq BASIC Version 3.8
for OpenVMS VAX Systems

Operating System and Version: OpenVMS Alpha Version 7.1 or higher
(with IEEE floating-point support);
OpenVMS Alpha Version 6.1 or higher
(without IEEE floating-point support); or
OpenVMS VAX Version 5.5-2 or higher

Compaq Computer Corporation
Houston, Texas

© 2000 Compaq Computer Corporation

COMPAQ, VAX, VMS, the Compaq logo, and the DIGITAL logo Registered in U.S. Patent and Trademark Office.

Alpha, DEC BASIC, OpenVMS, and VAX BASIC are trademarks of Compaq Information Technologies Group, L.P.

Motif is a trademark of The Open Group.

All other product names mentioned herein may be the trademarks or registered trademarks of their respective companies.

Confidential computer software. Valid license from Compaq or authorized sublicensor required for possession, use, or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard commercial license.

Compaq shall not be liable for technical or editorial errors or omissions contained herein.

The information in this publication is subject to change without notice and is provided "AS IS" WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK ARISING OUT OF THE USE OF THIS INFORMATION REMAINS WITH RECIPIENT. IN NO EVENT SHALL COMPAQ BE LIABLE FOR ANY DIRECT, CONSEQUENTIAL, INCIDENTAL, SPECIAL, PUNITIVE, OR OTHER DAMAGES WHATSOEVER (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, OR LOSS OF BUSINESS INFORMATION), EVEN IF COMPAQ HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THE FOREGOING SHALL APPLY REGARDLESS OF THE NEGLIGENCE OR OTHER FAULT OF EITHER PARTY AND REGARDLESS OF WHETHER SUCH LIABILITY SOUNDS IN CONTRACT, NEGLIGENCE, TORT, OR ANY OTHER THEORY OF LEGAL LIABILITY, AND NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.

The limited warranties for Compaq products are exclusively set forth in the documentation accompanying such products. Nothing herein should be construed as constituting a further or additional warranty.

ZK5424

The Compaq OpenVMS documentation set is available on CD-ROM.

Contents | Index

# Preface

Compaq BASIC for OpenVMS Alpha is the new name for DEC BASIC. Compaq BASIC for OpenVMS VAX is the new name for VAX BASIC. Any references to the former names in product documentation or other components should be construed as references to the Compaq BASIC names. Any references to BASIC or to Compaq BASIC apply to both products unless otherwise specified. References to Alpha BASIC mean Compaq BASIC for OpenVMS Alpha, and references to VAX BASIC mean Compaq BASIC for OpenVMS VAX.

This manual describes how to develop and use BASIC programs on OpenVMS systems and describes BASIC language features.

# Intended Audience

This manual is intended for programmers who compile, link, and execute BASIC programs on OpenVMS systems. Users should have a working knowledge of BASIC or another high-level programming language, the Digital Command Language (DCL), and DCL command procedures.

# Document Structure

This manual contains the following chapters and appendixes:

Part 1 Developing BASIC Programs on OpenVMS Systems

- Chapter 1 provides a brief overview of BASIC.
- Chapter 2 describes how to develop programs in the VAX BASIC Environment (VAX BASIC only).
- Chapter 3 describes how to develop programs at DCL command level and how to generate a compiler listing.
- Chapter 4 describes how to use the OpenVMS Debugger to debug BASIC programs.

Part 2 BASIC Programming Concepts

- Chapter 5 explains how to get started with BASIC.
- Chapter 6 explains simple input and output procedures.
- Chapter 7 shows how to use arrays.
- Chapter 8 explains data definitions.
- Chapter 9 explains how to create user-defined data structures with the RECORD statement.
- Chapter 10 shows how to control the flow of program execution.
- Chapter 11 explains how to use functions.
- Chapter 12 explains how to handle strings.
- Chapter 13 describes structured programming techniques.
- Chapter 14 explains how to manage files.
- Chapter 15 describes how to format output with the PRINT USING statement.
- Chapter 16 explains error-handling techniques.
- Chapter 17 shows how to use compiler directives.
- Chapter 18 describes how BASIC represents data.

Part 3 Using BASIC Features on OpenVMS Systems

- Chapter 19 describes additional I/O considerations on OpenVMS systems.
- Chapter 20 describes OpenVMS System Services and Run-Time Library routines.
- Chapter 21 describes the use of user-supplied libraries and shareable images.
- Chapter 22 describes how to use CDD/Repository capabilities.
- Chapter 23 describes using standard Motif Bindings with BASIC.

Appendixes

- Appendix A lists compile-time error messages.
- Appendix B lists run-time error messages.
- Appendix C provides an overview of the optional productivity tools.

# Platform Labels

A platform is a combination of operating system and central processing unit (CPU) that provides a distinct environment in which to use a product (in this case, a language). This manual contains information for the following language platforms:

- OpenVMS Alpha
- OpenVMS VAX

Information in this manual applies to both supported platforms, unless it is otherwise noted. Platform-specific information is noted in the manual as follows:

- Alpha BASIC refers to information that is correct for Compaq BASIC for OpenVMS Alpha systems.
- VAX BASIC refers to information that is correct for Compaq BASIC for OpenVMS VAX systems.

# Related Documents

For more information about language elements, syntax, and reference information, see the Compaq BASIC for OpenVMS Alpha and VAX Systems Reference Manual.

For additional information about OpenVMS products and services, access the following World Wide Web address:

    http://www.compaq.com/

# Reader's Comments

Compaq welcomes your comments on this manual. Please send comments to either of the following addresses:

Internet | basic_docs@compaq.com
Mail | Compaq Computer Corporation OSSG Documentation Group, ZKO3-4/U08 110 Spit Brook Rd. Nashua, NH 03062-2698

# How to Order Additional Documentation

If you have access to the World Wide Web, please visit our website at

      http://www.openvms.digital.com/commercial/basic/basic_index.html

Click Software Product Description, and read the ordering information. Note the order numbers of the documents you want. For pricing and further information, call 1--800--282-6672.

Use the following World Wide Web address for information about how to order OpenVMS operating system documentation:

    http://www.compaq.com/

If you need help deciding which documentation best meets your needs, call 1--800--282--6672.

# Conventions

In this manual, every use of the name Compaq BASIC or the name BASIC applies to both Compaq BASIC for OpenVMS Alpha and Compaq BASIC for OpenVMS VAX software.

Table 1 shows the conventions used in this manual.

Table 1 Conventions Used in This Manual
Convention | Description
--- | ---
$ | A dollar sign ($) represents the OpenVMS DCL system prompt.
`[Return]` | In examples, a key name enclosed in a box indicates that you press that key on the keyboard. (In text, a key name is not enclosed in a box.) In the HTML version of this document, this convention appears as brackets, rather than a box.
Ctrl/ x | The key combination Ctrl/ x indicates that you must hold down the key labeled Ctrl while you press another key, for example Ctrl/Y or Ctrl/Z.
KP n | The phrase KP n indicates that you must press the key labeled with the number or character n on the numeric keypad, for example, KP3 or KP-.
PF1 x | A sequence such as PF1 x indicates that you must first press and release the key labeled PF1, then press and release another key.
n | A lowercase italic n indicates the generic use of a number.
... | A horizontal ellipsis in examples indicates one of the following possibilities: Additional optional arguments in a statement have been omitted. The preceding item or items can be repeated one or more times. Additional parameters, values, or other information can be entered.
. . . | A vertical ellipsis indicates the omission of items from a code example or command format; the items are omitted because they are not important to the topic being discussed.
() | In format descriptions, parentheses indicate that you must enclose the options in parentheses if you choose more than one.
[] | In format descriptions, brackets indicate optional elements; you can select none, one, or all of the elements.
{ } | In format descriptions, braces indicate that one element in a list is required. You must choose one and only one from the list.
boldface text | Boldface text is used for the introduction of a new term.
italic text | Italic text represents parameters, arguments, and information that can vary in system messages (for example, Internal error number), as well as book titles and emphasized information.
UPPERCASE | Uppercase indicates the name of a command, routine, file, or file protection code, or the abbreviation for a system privilege.

Table 2 defines mnemonics and other terms used in the syntax diagrams.

Table 2 Mnemonics and Other Terms Used in Syntax
Term | Meaning
--- | ---
angle | Angle in radians or degrees
array | Array; syntax rules specify whether the bounds or dimensions can be specified
chnl | I/O channel associated with a file
chnl-exp | Numeric expression that specifies a channel number
com | Specific to a COMMON block
cond | Conditional expression; indicates that an expression can be either logical or relational
cond-exp | Conditional expression
const | Constant value
data-type | Data type keyword
decimal-var | Decimal variable
decl-item | Array, record, or variable
def | Specific to a DEF function
delim | Delimiter
equiv-name | File specification, device, or logical name to be assigned a logical name
err-num | Run-time error number
exp | Expression
ext-routine | External function
external-param | External parameter
file-spec | File specification
func | Specific to a FUNCTION subprogram
int | Integer value
int-const | Integer constant
int-exp | Expression that represents an integer value
int-var | Variable that contains an integer value
label | Alphanumeric statement label
lex | Lexical; used to indicate a component of a compiler directive
lex-exp | Lexical expression
lex-var | Lexical variable
line | Statement line; may or may not be numbered
line-num | Statement line number
lit | Literal value, in quotation marks
log-exp | Logical expression
log-name | 1- to 63-character logical name to be associated with equiv-name
macro-id | User identifier following the rules for BASIC identifiers
map | Specific to a MAP statement
matrix | Two-dimensional array
name | Name or identifier; indicates the declaration of a name or the name of a BASIC structure, such as a SUB subprogram
num | Numeric value
num-lit | Numeric literal
param-list | Parameter list, such as for a SUB subprogram
pass-mech | Valid BASIC passing mechanism
prog-name | Program name
real | Floating-point value
real-exp | Real expression
real-var | Real variable
rel-exp | Relational expression
relationship-type | Oracle CDD/Repository protocol
replacement-token | Identifier, keyword, compiler directive, literal constant, or operator
routine | SUB subprogram or other callable procedure
str | Character string
str-exp | Expression that represents a character string
str-lit | String literal
str-var | Variable that contains a character string
sub | Specific to a SUB subprogram
target | Target point of a branch statement; either a line number or a label
unq-str | Unique string
unsubs-var | Unsubscripted variable, as opposed to an array element
var | Variable

Next | Contents | Index