HP 3000 Manuals

OPTION [ HP Business BASIC/XL Reference Manual ] MPE/iX 5.0 Documentation


HP Business BASIC/XL Reference Manual

OPTION 

The OPTION and GLOBAL OPTION statements can change the program unit
characteristics shown in Table 4-10.  The value of each program unit
characteristic is initially set to the value in the HP Business BASIC/XL
configuration file, HPBBCNFG.PUB.SYS supplied with HP Business BASIC/XL.
The current values of each characteristic are displayed by the INFO
command.

          Table 4-10.  Changeable Program Unit Characteristics 

-----------------------------------------------------------------------------------------------
|                   |                                    |                                    |
|   Program Unit    |       Option (Default First)       |               Effect               |
|  Characteristic   |                                    |                                    |
|                   |                                    |                                    |
-----------------------------------------------------------------------------------------------
|                   |                                    |                                    |
| Default numeric   | REAL                               | Implicitly declared numeric        |
| type (type        | DECIMAL                            | variables are type REAL.           |
| assigned to       |                                    | Implicitly declared numeric        |
| implicitly        |                                    | variables are type DECIMAL.        |
| declared numeric  |                                    |                                    |
| variables).       |                                    |                                    |
|                   |                                    |                                    |
-----------------------------------------------------------------------------------------------
|                   |                                    |                                    |
| Initialization of | INIT                               | Numeric variables are initialized  |
| numeric variables | NOINIT                             | to zero.                           |
| to zero.          |                                    | Numeric variables are not          |
|                   |                                    | initialized to zero.               |
|                   |                                    |                                    |
-----------------------------------------------------------------------------------------------
|                   |                                    |                                    |
| Implicit variable | NODECLARE                          | Implicit variable declaration is   |
| declaration.  *   | DECLARE                            | legal.                             |
|                   |                                    | Implicit variable declaration is   |
|                   |                                    | illegal.                           |
|                   |                                    |                                    |
-----------------------------------------------------------------------------------------------
|                   |                                    |                                    |
| Default of lower  | BASE 0                             | Default lower bound is zero.       |
| bound of arrays.  | BASE 1                             | Default lower bound is one.        |
|                   |                                    |                                    |
-----------------------------------------------------------------------------------------------
|                   |                                    |                                    |
| Trace statement   | TRACE                              | Enables trace statements.          |
| output control.   | NOTRACE                            | Disables trace statements.         |
|                   |                                    |                                    |
-----------------------------------------------------------------------------------------------

Table 4-10 Note 

*   If an implicit variable declaration is illegal, using a variable that
    is not explicitly declared causes an error.  If the program is
    interpreted, the error occurs at run time; if the program is
    compiled, it occurs at compile time.

          Table 4-11.  Global Program Subunit Options 

-----------------------------------------------------------------------------------------------
|                       |                       |                                             |
|     Program Unit      |    Option (Default    |                   Effect                    |
|    Characteristics    |        First)         |                                             |
|                       |                       |                                             |
-----------------------------------------------------------------------------------------------
|                       |                       |                                             |
| Declare current       |                       | Current program starts multi-program        |
| program status in a   |                       | application.  NEWCOM allows new commons     |
| multi-program         |      [ NONEWCOM]      | when program loaded.  NONEWCOM prevents new |
| application.  Control | MAIN [ NEWCOM  ]      | commons.                                    |
| creation and deletion |                       |                                             |
| of COM areas.         |                       |                                             |
|                       |                       |                                             |
-----------------------------------------------------------------------------------------------
|                       |                       |                                             |
| **The MAIN and        |                       | Identifies current program as a module of   |
| SUBPROGRAM global     |                       | multi-program application, but not the      |
| options control both  | SUBPROGRAM            | initial main.  This program can not be RUN; |
| program execution and |                       | only a programmatic GET can run this        |
| the creation and      | [ NONEWCOM]           | program.  NEWCOM allows creation and        |
| deletion of common    | [ NEWCOM  ]           | deletion of COM blocks when the GET occurs. |
| areas.                |                       | NONEWCOM prevents this.                     |
|                       |                       |                                             |
-----------------------------------------------------------------------------------------------

Table 4-11 Note 

**  The default value if neither is specified is MAIN NONEWCOM. The value
    of this option is not set in the configuration utility nor is the
    value displayed in the INFO command's display.

Syntax 

[GLOBAL] OPTION option_list 

Parameters 

GLOBAL           Allowed only if the statement is in the main program.
                 If GLOBAL appears, the statement is a GLOBAL OPTION
                 statement; if GLOBAL is omitted, the statement is an
                 OPTION statement.  A GLOBAL OPTION statement affects
                 every program unit in the program.  An OPTION statement
                 affects only the program unit that contains it.

                 An OPTION statement overrides a GLOBAL OPTION statement,
                 but only while the program unit that contains it is
                 running.

option-list      A list of one to five unique options separated by
                 commas.  Each option can be one of each of the following
                 pairs:
                   DECIMAL or REAL
                   INIT or NOINIT
                   DECLARE or NODECLARE
                   BASE 0 or BASE 1
                   TRACE or NOTRACE

                 With GLOBAL specified, one of the following additional
                 options can also be specified:
                   MAIN
                   SUBPROGRAM
                   MAIN NONEWCOM
                   MAIN NEWCOM
                   SUBPROGRAM NONEWCOM
                   SUBPROGRAM NEWCOM

The term "OPTION x statement" where x is DECIMAL, REAL, INIT, NOINIT,
DECLARE, NODECLARE, TRACE, NOTRACE MAIN, or SUBPROGRAM means an OPTION or
GLOBAL OPTION statement that contains the OPTION x.  For example, the
line

     120 GLOBAL OPTION BASE 1, REAL, NOINIT, NODECLARE

can be called a GLOBAL OPTION statement, an OPTION BASE statement, an
OPTION REAL statement, an OPTION NOINIT statement, or an OPTION NODECLARE
statement.

If a program unit contains conflicting OPTION x statements, then the
option active in the subunit is determined by the OPTION or GLOBAL OPTION
statement with the highest line number.  An OPTION statement can reset
the same option that a GLOBAL OPTION statement has set in the main
program.

The following are the default options for a program unit without an
OPTION statement:

  REAL
  INIT
  NODECLARE
  BASE 0
  TRACE
  MAIN NONEWCOM

OPTION and GLOBAL OPTION statements are processed immediately before the
program units containing them are run.  Neither statement can be used as
a command.

The MAIN and SUBPROGRAM global options are used chiefly for compiling
multi-program applications.  A program that uses the SUBPROGRAM option
can only be run by execution of a GET program line from within an
executing program.  Trying to RUN a program in the interpreter that has a
GLOBAL OPTION SUBPROGRAM statement results in an error.  Programs that
contain the GLOBAL OPTION MAIN can be executed by using the RUN command
in the interpreter as well as by executing a GET statement for that
program in an executing program.

A suboption of the MAIN/SUBPROGRAM option is NONEWCOM or NEWCOM. The
suboption relevant at the execution of the GET statement is that in the
called program unit, not that suboption present in the caller.  The
NONEWCOM suboption prevents the deletion and addition of COM areas
regardless of whether the called program uses the COM area.  COM areas
named in both the calling and called programs are checked to ensure that
the declarations in each match.  NONEWCOM is the active suboption if
neither suboption is specified.  The NONEWCOM suboption causes every
programmatic GET to compare COM area names.  Any COM areas not named in
both programs are deleted and any COM areas named only in the new program
are created.

Examples 

The comments in the following example explain the extent that local
OPTION statements override the GLOBAL OPTION statement in the main
program.

     100 GLOBAL OPTION DECIMAL, INIT, DECLARE, BASE 0
         .
         .
     125 CALL Sub1
         .
         .
     150 CALL Sub2
         .
         .
     175 CALL Sub3
         .
         .
     200 SUB Sub1
     210 OPTION REAL, NOINIT   !Options: REAL,NOINIT,DECLARE,BASE 0
         .
         .
     250 SUBEND
     300 SUB Sub2
     310 OPTION NODECLARE
     320 OPTION BASE 1         !Options: DECIMAL, INIT, NODECLARE, BASE 1
         .
         .
     350 SUBEND
     400 SUB Sub3
     410 OPTION DECIMAL        !Options: Same as global options
         .
         .
     450 SUBEND
     999 END

Each of the following three programs declares the variable A implicitly.
In the first and third programs, A is real.  In the second program, A is
decimal.

     10 OPTION REAL          10 OPTION DECIMAL        10 REM No option specified
     20 A = PI               20 A = PI                20 A = PI
     99 END                  99 END                   99 END

In the first and second programs below, the variables are initialized to
zero when the program is run; in the third, they are not.

     10 OPTION INIT          10 REM No option specified   10 OPTION NOINIT
     20 INTEGER X,Y,Z        20 REAL A,B,C,D,E            20 DECIMAL P,Q
     99 END                  99 END                       99 END

In the first and second programs below, implicit variable declaration is
legal.  Numeric variable X and string variable A$ are implicitly
declared, and no error occurs.  In the third program, implicit variable
declaration is illegal.  A run-time error occurs at line 20.

     10 OPTION NODECLARE      10 REM No option specified  10 OPTION DECLARE
     20 X = 4535              20 X = 4535                 20 X = 4535
     30 A$ = "Hi"             30 A$ = "Hi"                30 A$ = "Hi"
     99 END                   99 END                      99 END

Each of the following programs declares numeric array A and string array
B$.  In the first and second programs, the arrays have lower bounds zero.
Therefore, A has six elements and B$ has 15 (three rows and five
columns).  In the third program, the arrays have lower bound one.  Array
A has five elements and B$ has eight (two rows and four columns).  For
more information, see "Array Variables" in chapter 3.

     10 OPTION BASE 0         10 REM No option specified   10 OPTION BASE 1
     20 DIM A(5)              20 DIM A(5)                  20 DIM A(5)
     30 DIM B$(2,4)           30 DIM B$(2,4)               30 DIM B$(2,4)
     99 END                   99 END                       99 END

An example of the MAIN/SUBPROGRAM global option requires the definition
of a program file in addition to the program currently in the
interpreter.  The example demonstrates the allocation of new and
deallocation of old common areas.

     >LIST
          10 ! current program in the interpreter
          20 GLOBAL OPTION MAIN NONEWCOM
          30 COM /Com1/ Main1,Main2
          40 COM /Com2/Main3,Main4
          50 Main1=1;Main2=2;Main3=3;Main4=4

          .

          .

          .
     >RUN
      1  2  0  0

     >LIST
      ! SUBFILE
         10 ! program in SUBFILE
         20 GLOBAL OPTION SUBPROGRAM NEWCOM
         30 COM /Com1/ Sub1,Sub2
         40 COM /Com3/ Sub3,Sub4
         50 PRINT Sub1;Sub2;Sub3;Sub4

The NONEWCOM/NEWCOM option in the called program in SUBFILE states that
new common areas can be allocated.  This allows allocation of Com3.
Since Com2 is not used in the program in SUBFILE, Com2 is deallocated.
As can be seen by program execution, the values assigned to the Com1
common area variables in the callee are those referenced by the variables
in Com1 in the called program.



MPE/iX 5.0 Documentation