Compaq BASIC for OpenVMS
Alpha and VAX Systems
Reference Manual


Previous Contents Index


%LET

The %LET directive declares and provides values for lexical variables. You can use lexical variables only in conditional expressions in the %IF-%THEN-%ELSE directive and in lexical expressions in subsequent %LET directives.

Format



Syntax Rules

  1. Lex-var is the name of a lexical variable. Lexical variables are always LONG integers.
  2. Lex-var must be preceded by a percent sign (%) and cannot end with a dollar sign ($) or percent sign.
  3. Lex-exp can be any of the following:

Remarks

  1. Only a line number or a comment field can appear on the same physical line as the %LET directive.
  2. You cannot change the value of lex-var within a program unit once it has been named in a %LET directive. For more information about coding conventions, see the Compaq BASIC for OpenVMS Alpha and VAX Systems User Manual.

Example


%LET %DEBUG_ON = 1% 


%LIST

The %LIST directive causes the BASIC compiler to start or resume accumulating compilation information for the program listing file.

Format



Syntax Rules

None


Remarks

  1. Only a line number or a comment field can appear on the same physical line as the %LIST directive.
  2. The %LIST directive has no effect unless you requested a listing file. For more information about listing file format, see the Compaq BASIC for OpenVMS Alpha and VAX Systems User Manual.
  3. As soon as it encounters the %LIST directive, the BASIC compiler starts or resumes accumulating information for the program listing file. Thus, the directive itself appears as the next line in the listing file.

Example


%LIST 


%NOCROSS

The %NOCROSS directive causes the BASIC compiler to stop accumulating cross-reference information for the program listing file.

Format



Syntax Rules

None


Remarks

  1. Only a line number or a comment field can appear on the same physical line as the %NOCROSS directive.
  2. The BASIC compiler stops accumulating cross-reference information for the program listing file immediately after encountering the %NOCROSS directive.
  3. The %NOCROSS directive has no effect unless you request a listing file and cross-reference information.
  4. It is recommended that you do not embed a %NOCROSS directive within a statement. Embedding a %NOCROSS directive within a statement makes the accumulation of cross-reference information unpredictable. For more information about listing file format, see the Compaq BASIC for OpenVMS Alpha and VAX Systems User Manual.

Example


%NOCROSS 


%NOLIST

The %NOLIST directive causes the BASIC compiler to stop accumulating compilation information for the program listing file.

Format



Syntax Rules

None


Remarks

  1. Only a line number or a comment field can appear on the same physical line as the %NOLIST directive.
  2. As soon as it encounters the %NOLIST directive, the BASIC compiler stops accumulating information for the program listing file. Thus, the directive itself does not appear in the listing file.
  3. The %NOLIST directive has no effect unless you requested a listing file.
  4. In BASIC, you can override all %NOLIST directives in a program with the /SHOW=OVERRIDE qualifier. For more information about listing file format, see the Compaq BASIC for OpenVMS Alpha and VAX Systems User Manual.

Example


%NOLIST 


%PAGE

The %PAGE directive causes BASIC to begin a new page in the program listing file.

Format



Syntax Rules

None


Remarks

  1. Only a line number or a comment field can appear on the same physical line as the %PAGE directive.
  2. The %PAGE directive has no effect unless you request a listing file.

Example


%PAGE 


%PRINT

The %PRINT directive lets you insert a message into your source code that the BASIC compiler prints during compilation.

Format



Syntax Rules

None


Remarks

  1. Only a line number or a comment field can appear on the same physical line as the %PRINT directive.
  2. BASIC will print the message specified as soon as it encounters a %PRINT directive. Str-lit is displayed on the terminal screen and in the compilation listing.

Example


%IF %DEBUG = 1% %THEN 
%PRINT "This is a debug compilation" 

Output


%BASIC-S-USERPRINT, This is a debug compilation 


%REPORT

The %REPORT directive lets you record a dependency relationship between the compiled module entity for your program and the data definitions in Oracle CDD/Repository dictionaries. The data definitions are not copied into the program.

Format



Syntax Rules

  1. Str-lit specifies a path name in a CDO-format dictionary. It can be either a DMU-format path name or a CDO-format path name, enclosed in quotation marks. This specifies a dictionary entity, such as a form definition or an Rdb/VMS database, that the program references.
  2. Relationship-type specifies a valid Oracle CDD/Repository protocol; it must be enclosed in quotation marks if specified. The default relationship-type is CDD$COMPILED_DEPENDS_ON.

Remarks

  1. For this directive to be meaningful, you must specify the /DEPENDENCY_DATA qualifier at compile time. If /DEPENDENCY is not specified, the compiler will simply check the syntax and otherwise ignore the %REPORT directive.
  2. Your current CDD$DEFAULT and str-lit must refer to CDO-format dictionaries (not necessarily the same one).
  3. If you specify the /DEPENDENCY_DATA qualifier to the compiler, and if CDD$DEFAULT points to a CDO-format dictionary, a compiled module entity is created in CDD$DEFAULT for each compilation unit. No compiled module entity is created if both conditions are not true.
  4. The %REPORT %DEPENDENCY directive creates a dependency relationship in the dictionary between the compiled module entity for the program and the CDO-format dictionary entity to which it refers.

Example


!Establish access to the form PINK_SLIP in a dictionary 
!on a specified node, and report the program's dependency 
!relationship with the form.  
%REPORT %DEPENDENCY "MYNODE::MY$DISK:[MYDIR]PERSONNEL.FORMS.PINK_SLIP" 
!Relationship is CDD$COMPILED_DEPENDS_ON, the default. 


%SBTTL

The %SBTTL directive lets you specify a subtitle for the program listing file.

Format



Syntax Rules

Str-lit can contain up to 45 characters in VAX BASIC and 31 characters in Alpha BASIC.


Remarks

  1. BASIC truncates extra characters from str-lit and does not signal a warning or error. In Alpha BASIC, str-lit is truncated at 31 characters. In VAX BASIC, str-lit is truncated at 45 characters.
  2. Only a line number or a comment field can appear on the same physical line as the %SBTTL directive.
  3. The specified subtitle appears underneath the title on the second line of all pages of source code in the listing file until the BASIC compiler encounters another %SBTTL or %TITLE directive. BASIC clears the subtitle field before the allocation map section of the listing is generated. This way, you only get a subtitle on the listing pages that contain source code.
  4. Because BASIC associates a subtitle with a title, a new %TITLE directive sets the current subtitle to the null string. In this case, no subtitle appears in the listing until BASIC encounters another %SBTTL directive.
  5. If you want a subtitle to appear on the first page of your listing, the %SBTTL directive should appear at the beginning of your program, immediately after the %TITLE directive. Otherwise, the subtitle will start to appear only on the second page of the listing.
  6. If you want the subtitle to appear on the page of the listing that contains the %SBTTL directive, the %SBTTL directive should immediately follow a %PAGE directive or a %TITLE directive that follows a %PAGE directive.
  7. The %SBTTL directive has no effect unless you request a listing file.

Example


100     %TITLE "Learning to Program in BASIC" 
        %SBTTL "Using FOR-NEXT Loops" 
        REM     THIS PROGRAM IS A SIMPLE TEST 
200     DATA    1, 2, 3, 4 
   .
   .
   .
        NEXT I% 
300     END 

Output


TEST$MAIN                      Learning to Program in BASIC
                               Using FOR-NEXT Loops 
 
     1         100     %TITLE "Learning to Program in BASIC" 
     2                 %SBTTL "Using FOR-NEXT Loops" 
     3                 REM THIS PROGRAM IS A SIMPLE TEST 
     4         200     DATA  1, 2, 3, 4 
   .
   .
   .
    10                 NEXT I% 
    11         300     END 


%TITLE

The %TITLE directive lets you specify a title for the program listing file.

Format



Syntax Rules

Str-lit can contain up to 45 characters in VAX BASIC and up to 31 characters in Alpha BASIC.


Remarks

  1. BASIC truncates extra characters from str-lit and does not signal a warning or error. In Alpha BASIC, str-lit is truncated at 31 characters. In VAX BASIC, str-lit is truncated at 45 characters.
  2. Only a line number or a comment field can appear on the same physical line as the %TITLE directive.
  3. The specified title appears on the first line of every page of the listing file until BASIC encounters another %TITLE directive in the program.
  4. The %TITLE directive should appear on the first line of your program, before the first statement, if you want the specified title to appear on the first page of your listing.
  5. If you want the specified title to appear on the page that contains the %TITLE directive, the %TITLE directive should immediately follow a %PAGE directive.
  6. Because BASIC associates a subtitle with a title, a new %TITLE directive sets the current subtitle to the null string.
  7. The %TITLE directive has no effect unless you request a listing file.

Example


100     %TITLE "Learning to Program in BASIC" 
        REM THIS PROGRAM IS A SIMPLE TEST 
200     DATA 1, 2, 3, 4 
   .
   .
   .
        NEXT I% 
300     END 

Output


TEST$MAIN                      Learning to Program in BASIC
 
     1         100     %TITLE "Learning to Program in BASIC" 
     2                 %SBTTL "Using FOR-NEXT Loops" 
     3                 REM THIS PROGRAM IS A SIMPLE TEST 
     4         200     DATA 1, 2, 3, 4 
   .
   .
   .
 
    10                 NEXT I% 
    11         300     END 


%UNDEFINE

The %UNDEFINE directive causes BASIC to undefine an identifier that was previously defined with the %DEFINE directive.

Format



Syntax Rules

Macro-id is a user identifier that follows the rules for a BASIC identifier.


Remarks

  1. The %UNDEFINE directive cancels a previous definition of macro-id by a %DEFINE.
  2. The %UNDEFINE directive may appear with included code and will cancel the definition of an identifier that was previously defined.

Example


 G = 6% 
 PRINT "G ="; G 
 %DEFINE G "anything" 
 PRINT "G = "; G 
 %UNDEFINE G 
 PRINT "G ="; G 

Output


 G = 6 
 G = anything 
 G = 6 


%VARIANT

The %VARIANT directive is a built-in lexical function that allows you to conditionally control program compilation. %VARIANT returns an integer value when you reference it in a lexical expression. You set the variant value with the /VARIANT qualifier when you compile the program or with the SET VARIANT command. If the /VARIANT qualifier or the SET VARIANT command is not used, the value of %VARIANT is 0.

Format



Syntax Rules

None


Remarks

  1. The %VARIANT function can appear only in a lexical expression.
  2. The %VARIANT function returns the integer value specified either with the COMPILE /VARIANT command, the SET /VARIANT command, or the DCL command BASIC. The returned integer always has a data type of LONG.

Example


%LET %VMS = 0 
%LET %RSX = 1 
%LET %RSTS = 2 
 
%IF %VARIANT = %VMS 
    %THEN 
       . 
       . 
       . 
 
%ELSE %IF %VARIANT = %RSX OR %VARIANT = %RSTS 
    %THEN 
       . 
       . 
       . 
 
    %ELSE %ABORT "Illegal compilation variant" 
    %END %IF 
 
%END %IF 


Chapter 4
Statements and Functions

This chapter provides reference material on all of the BASIC statements and functions. The shortened forms Alpha BASIC and VAX BASIC refer to Compaq BASIC for OpenVMS Alpha and Compaq BASIC for OpenVMS VAX, respectively.

The statements and functions are listed in alphabetical order and each description contains the following format:
Definition A description of what the statement does.
Format The required syntax for the statement.
Syntax Rules Any rules governing the use of parameters, separators, or other syntax items.
Remarks Explanatory remarks concerning the effect of the statement on program execution and any restrictions governing its use.
Example One or more examples of the statement in a BASIC program. Where appropriate, sample output is also shown.


ABS

The ABS function returns a floating-point number that equals the absolute value of a specified floating-point expression.

Format



Syntax Rules

None


Remarks

  1. The argument of the ABS function must be a real expression. When the argument is a real expression, BASIC returns a value of the same floating-point size. When the argument is not a real expression, BASIC converts the argument to the default floating-point size and returns a value of the default floating-point size.
  2. The returned floating-point value is always greater than or equal to zero. The absolute value of 0 is zero. The absolute value of a positive number equals that number. The absolute value of a negative number equals that number multiplied by -1.

Example


G = 5.1273 
A = ABS(-100 * G) 
B = -39 
PRINT ABS(B), A 

Output


 39             512.73 


ABS%

The ABS% function returns an integer that equals the absolute value of a specified integer expression.

Format



Syntax Rules

None


Remarks

  1. If you specify a floating-point expression for int-exp, BASIC truncates it to an integer.
  2. The returned value is always greater than or equal to zero. The absolute value of 0 is zero. The absolute value of a positive number equals that number. The absolute value of a negative number equals that number multiplied by -1.

Example


G% = 5.1273 
A = ABS%(-100% * G%) 
B = -39 
PRINT ABS%(B), A 

Output


 39            500 


ASCII

The ASCII function returns the ASCII value in decimal of a string's first character.

Format



Syntax Rules

None


Remarks

  1. The ASCII value of a null string is zero.
  2. The ASCII function returns an integer value of the default size from 0 to 255.

Example


DECLARE STRING time_out 
time_out = "Friday" 
PRINT ASCII(time_out) 

Output


 70 


ATN

The ATN function returns the arctangent (that is, angular value) of a specified tangent in radians or degrees.

Format



Syntax Rules

None


Remarks

  1. The returned angle is expressed in radians or degrees, depending on which angle clause you choose with the OPTION statement.
  2. ATN returns a value from --PI/2 to PI/2 when you request the result in radians via the OPTION statement. It returns a value from -90 to 90 when you request the result in degrees.
  3. The argument of the ATN function must be a real expression. When the argument is a real expression, BASIC returns a value of the same floating-point size. When the argument is not a real expression, BASIC converts the argument to the default floating-point size and returns a value of the default floating-point size.

Example


OPTION ANGLE = RADIANS 
DECLARE SINGLE angle_rad, angle_deg, T 
INPUT "Tangent value";T 
angle_rad = ATN(T) 
PRINT "The smallest angle with that tangent is" ;angle_rad; "radians" 
angle_deg = angle_rad/(PI/180) 
PRINT "and"; angle_deg; "degrees" 

Output


Tangent value? 2 
The smallest angle with that tangent is 1.10715 radians 
and 63.435 degrees 


Previous Next Contents Index