HP 3000 Manuals

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


HP Business BASIC/XL Reference Manual

SUB 

The SUB statement defines the beginning of a subprogram.  It is not
executable.

Syntax 

{SUBPROGRAM}
{SUB       } sub_name [(f_param [, f_param]...)]

Parameters 

sub_name         Subprogram name.  This is an identifier.

f_param          A formal parameter.  One of the following:

                 [type ] num_var           num_var is a numeric variable
                                           and type is one of the
                                           following:
                                             SHORT
                                             SHORT REAL
                                             SHORT INTEGER
                                             SHORT DECIMAL
                                             REAL
                                             INTEGER
                                             DECIMAL

                                           If type is not specified,
                                           num_var is declared with the
                                           default numeric type.  If type 
                                           is specified, it determines
                                           the type of each num_var 
                                           between it and the next type 
                                           or the next nonnumeric
                                           f_param.

                 str_var$                  String variable.  Its maximum
                                           length is the same as that of
                                           the actual parameter.

                 [ type ] num_var          Abbreviated numeric array
                 ([*[,*]...])              declaration, with one asterisk
                                           per dimension or no asterisks.
                                           No asterisks specifies any
                                           number of dimensions.  Either
                                           format is legal, but the
                                           format without asterisks is
                                           noncompilable when there is no
                                           reference in the subunit that
                                           allows the compiler to
                                           determine the number of
                                           dimensions for the array.

                                           type is one of the following:
                                             SHORT
                                             SHORT REAL
                                             SHORT INTEGER
                                             SHORT DECIMAL
                                             INTEGER
                                             REAL
                                             DECIMAL

                                           If type is not specified,
                                           num_var is declared with the
                                           default numeric type.  If type 
                                           is specified, it determines
                                           the type of each num_var 
                                           between it and the next type 
                                           or the next nonnumeric
                                           f_param.

                 str_var$ ([*[,*]...])     Abbreviated string array
                                           declaration, with one asterisk
                                           per dimension or no asterisks.
                                           No asterisks specifies any
                                           number of dimensions.  Either
                                           format is legal, but the
                                           format without asterisks is
                                           noncompilable.  The maximum
                                           length of each element is the
                                           same as declared for the
                                           actual parameter by the
                                           calling program unit.

                 #fnum                     A file designator.  fnum is a
                                           positive short integer greater
                                           than zero.  The file
                                           designated by the actual
                                           parameter file designator is
                                           referenced by #fnum within the
                                           subprogram.

Examples 

     SUBPROGRAM Sub1 (A(*), B$(*,*), INTEGER X,Y, P$, C,D, #15)
     SUB Sub2 (A(), B$(*), INTEGER X,Y P$, C,D, #15)

The above statements define the beginning of subprograms named Sub1 and
Sub2 that have the following formal parameters:

Parameter        Type 

A                Array of default numeric type.
B$               A 2-dimensional string array variable in Sub1.
                 A 1-dimensional string array variable in Sub2.
X and Y          Integer variables.
P$               String variable.
C and D          Variables of default numeric type.
#15              File designator.


NOTE If a program has more than one subprogram with the same name, all calls refer to the first one; that is, the one with the lowest-numbered SUBPROGRAM statement. The others cannot be called.


MPE/iX 5.0 Documentation