HP 3000 Manuals

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


HP Business BASIC/XL Reference Manual

Unformatted Output 

This section explains how to produce unformatted output on an output
device:

 *  Unformatted output statements that have one of the following
    characteristics:
     *  Produce output, but do not specify format.
     *  Are the BEEP, DISP, and PRINT statements.

 *  Numeric format statements that have the following characteristic:

     *  Specify format for numeric output of the DISP and PRINT
        statements.

 *  Output device specification statements that performs one of the
    following:

     *  Directs output to specific output devices.

     *  If a program does not contain output device specification
        statements, then all output from the program and the HP Business
        BASIC/XL interpreter is displayed on the standard list device.
        If HP Business BASIC/XL is running interactively, the standard
        list device is the terminal.  If HP Business BASIC/XL is running
        in a job stream, the standard list device is the line printer of
        the computer system that HP Business BASIC/XL is running on.  The
        MARGIN statement sets the terminal screen margin.

Each statement is defined in chapter 4.

The Display List 

Commas and Semicolons in Display List.  A comma or semicolon in the
display list separates individual output items in the output_item_list.
Table 6-5 summarizes the differences between commas and semicolons as
separators.

          Table 6-5.  Semicolon vs Comma in Display List 

-----------------------------------------------------------------------------------------------
|                   |                                    |                                    |
|     Separator     |      Second item is displayed      |  Display Enhancements Active from  |
|                   |                                    |      First Item Remain Active      |
|                   |                                    |                                    |
-----------------------------------------------------------------------------------------------
|                   |                                    |                                    |
| Semicolon         | Immediately after first item.      |                Yes.                |
|                   |                                    |                                    |
-----------------------------------------------------------------------------------------------
|                   |                                    |                                    |
| Comma             | At beginning of next output field. |                No.                 |
|                   |                                    |                                    |
-----------------------------------------------------------------------------------------------

If a DISP or PRINT statement ends with a comma or a semicolon, then it
does not print a carriage return and a line feed after its display list.
Subsequent output appears on the same line.

If a DISP or PRINT statement does not end with a comma or semicolon, it
prints a carriage return and a line feed after its display list.
Subsequent output to the same device appears on the next line.

Array References in Display List.  The DISP or PRINT statement prints an
array in row-major order; that is, the rightmost subscript varies
fastest.  Each time the rightmost subscript reaches its maximum value,
the DISP or PRINT statement prints a carriage return and a line feed.

The spacing of array elements depends on what follows the array
specification in the display list, as shown in Table 6-6.

          Table 6-6.  Semicolon vs Comma After an Array 

-----------------------------------------------------------------------------------------------
|                   |                                    |                                    |
|    If array is    |    Numeric elements are printed    |    String elements are printed     |
|    followed by    |                                    |                                    |
|                   |                                    |                                    |
-----------------------------------------------------------------------------------------------
|                   |                                    |                                    |
| Semicolon         | Side by side.                      | On consecutive output lines.       |
|                   |                                    |                                    |
-----------------------------------------------------------------------------------------------
|                   |                                    |                                    |
| Comma             | In consecutive output fields.      | On consecutive output lines.       |
|                   |                                    |                                    |
-----------------------------------------------------------------------------------------------
|                   |                                    |                                    |
| Nothing (it is    | In consecutive output fields.      | On consecutive output lines.       |
| the last item in  |                                    |                                    |
| the list)         |                                    |                                    |
|                   |                                    |                                    |
-----------------------------------------------------------------------------------------------

The DISP or PRINT statement prints two blank lines after printing the
entire array.

An array can also be printed with the MAT PRINT statement, described in
chapter 4.

Output Functions in Display List.  The display list of a DISP or PRINT
statement can contain any of the following output function calls:

     CTL (num_expr)
     END
     LIN (num_expr)
     PAGE
     SPA (num_expr)
     TAB (num_expr)

Each output function call directs the DISP or PRINT statement to print
one or more control characters on the output file or device.  If a
control character is sent to an output file, it affects the operation of
the line printer that prints the output file.  If a control character is
sent to an output device, it affects the device itself.

The following paragraphs explain the individual output functions, using
these terms:

n       Value of num_expr; for example, n is 10 in "TAB 2*5".

cl      Number of the current output line; for example, cl is 12 if the
        next output item is printed on the twelfth line of the output
        file.

cc      Number of the current output character position; for example, cc 
        is 20 if the first character of the next output item will be
        printed in the twentieth character position of the output line.

m       The right page margin, output line length.  It is set with the
        MARGIN parameter in the output device specification.  See "Device
        Specification Syntax" for more information.

CTL     The CTL function returns the carriage control character that is
        represented by n.  On the operating system in which HP Business
        BASIC/XL is running, n must be the code for a carriage control
        character.  HP Business BASIC/XL does not check this.  The DISP
        or PRINT statement prints the output items that precede the CTL
        call prior to generating the carriage control character.  For the
        effects of specific carriage control characters, see the manual
        for the operating system in which HP Business BASIC/XL is
        running.

END     The END function returns the end-of-file character.  It can only
        be used when the specified output device is a file.

LIN     The LIN function returns ABS(n) line feed characters.

        If n is positive, the following occurs:

          "LIN (num_expr)" specifies n line feed characters and a
          carriage return character.  The next output item is printed at
          the beginning of line cl+n.

        If n is zero, the following occurs:

          "LIN (num_expr)" specifies only a carriage return character
          (zero line feed characters).  The next output item is printed
          at the beginning of line cl (line cl is overwritten).

        If n is negative, the following occurs:

          "LIN (num_expr)" specifies -n line feed characters and no
          carriage return character.  The next output item is printed on
          line cl+(-n), starting at character position cc+1.

PAGE    The PAGE function returns a form feed character.  When the file
        is printed, the form feed character advances the line printer to
        the next physical page.  PAGE affects only ASCII files opened
        with carriage control specified.  If the output device is a
        terminal, or an ASCII file with no carriage control specified,
        PAGE has no effect.

SPA     The SPA function returns n spaces or a carriage return character
        if the current output line has fewer than n spaces left; that is,
        if cc+n exceeds m.

        If n is positive, the following occurs:

          The next output item is printed on the current output line,
          starting at character position cc+n, if possible.

        If cc+n exceeds m, the following occurs:

          The SPA call specifies a carriage return character.  The next
          output item is printed at the beginning of line cl+1.

        If n is negative, the following occurs:

          An error occurs.

TAB     The TAB function resets cc (and prints a carriage return
        character, if necessary).

        If n is positive, the following occurs:

          If TAB increases cc and n <=m then the next output item is
          printed on line cl, starting at character position n.  If TAB
          increases cc and n exceeds m, the next output item is printed
          on line cl+1 starting at character position n MOD m.  If TAB
          decreases cc, the next output item is printed on line cl+1,
          starting at character position cc.

        If n is zero, the following occurs:

          The TAB call has no effect.

        If n is negative, the following occurs:

          An error occurs.

Unless the output function call is the last item in the output list, HP
Business BASIC/XL ignores the delimiter (comma or semicolon) following
it.  If that delimiter is immediately followed by one or more commas, HP
Business BASIC/XL skips one output field for each comma.  For example,
the first comma in PRINT PAGE,,,A has no effect, but HP Business BASIC/XL
skips one output field for the second comma and another for the third.

Numeric Format Statements 

The FIXED, FLOAT, and STANDARD statements are numeric format statements.
Each statement specifies a different default numeric format--fixed-point,
floating-point, or standard, respectively.  The unformatted output
statements, DISP and PRINT output numeric values in the default numeric
format.

Before the program executes a numeric format statement, the default
numeric format is standard.

If a program contains more than one numeric format statement, the most
recently executed statement applies, with one exception:  numeric format
statements in a subunit are canceled when control returns to the calling
program unit.

Examples 

      10 FIXED 2             !Fixed-point format goes into effect
      15 INPUT X
      16 PRINT X             !Print X in fixed-point format
      20 CALL Sub1(X)        !Call Sub1; format is fixed-point
      30 PRINT X             !Print X in floating-point format
      99 END
     100 SUB Sub1(N)
     105   PRINT N           !Print N in fixed-point format
     110   STANDARD          !Standard format goes into effect
     115   PRINT N           !Print N in standard format
     116   CALL Sub2(N)      !Call Sub2; format is standard
     117   PRINT N           !Print N in standard format
     120 SUBEND              !Return to line 30 and floating-point format
     200 SUB Sub2(P)
     210   PRINT P           !Print P in standard format
     220   FLOAT 4           !Floating-point format goes into effect
     230   PRINT P           !Print P in floating-point format
     240 SUBEND              !Return to line 117 and floating-point format

If 125.7689 is entered for x in line 5, the above program prints:

     ?125.7689
      125.77
      125.77
      125.7689
      125.7689
      1.2577 E+02
      1.2577 E+02
      1.2577 E+02

Output Device Specification 

The SEND OUTPUT TO, SEND SYSTEM OUTPUT TO, and COPY ALL OUTPUT TO are
output specification statements.  Table 6-7 indicates what they specify.

          Table 6-7.  Device Specification Statements 

---------------------------------------------------------------------------------------------
|                                             |                                             |
|       Device Specification Statement        |                  Specifies                  |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| SEND OUTPUT TO                              | Device for PRINT statement output.          |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| SEND SYSTEM OUTPUT TO                       | System printer.                             |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| COPY ALL OUTPUT TO                          | Device for interpreter and program output.  |
|                                             |                                             |
---------------------------------------------------------------------------------------------

Each of these statements is defined in chapter 4.

If an output specification statement specifies a spooled output device,
HP Business BASIC/XL opens a spool file.  If a subsequently executed
output specification statement specifies the same spooled device, HP
Business BASIC/XL closes the spool file that it opened for the first
statement and opens another spool file.  Unless the first spool file is
the standard list device, it is ready for printing when HP Business
BASIC/XL closes it.  See "Spooled Output Devices" for more information.

If a program does not contain output device specification statements,
then all output from the program and the HP Business BASIC/XL interpreter
is displayed on the standard list device.  If HP Business BASIC/XL is
running interactively, the standard list device is the terminal.  If HP
Business BASIC/XL is running in a job stream, the standard list device is
the line printer of the computer system HP Business BASIC/XL is running
on.

An output specification statement in any program unit affects the entire
program.  If a program contains more than one SEND OUTPUT TO, SEND SYSTEM
OUTPUT TO, or COPY ALL OUTPUT TO statement, the most recently executed
one applies.  It cancels any previously executed statement of its kind,
but not output specification statements of another kind.  For example, a
SEND OUTPUT TO statement cancels any previously executed SEND OUTPUT TO
statements, but not SEND SYSTEM OUTPUT TO or COPY ALL OUTPUT TO
statements.

Spooled Output Devices.  If an output device specification statement
specifies a spooled device, HP Business BASIC/XL opens a spool file.  If
a subsequently executed output device specification statement specifies
the same spooled device, HP Business BASIC/XL closes the spool file that
it opened for the first statement and opens another one unless the
spooled device is PRINTER. See the next paragraph for information about
spooled device PRINTER. For example, if *LP is a file reference to a
spooled device, then when HP Business BASIC/XL executes the statement
SEND OUTPUT TO "*LP", it opens a spool file for PRINT statement output.
If HP Business BASIC/XL then executes the statement SEND SYSTEM OUTPUT TO
"*LP", it closes the spool file that it opened for PRINT statement output
and opens another spool file for system output.

If the standard list device is a spooled device, then HP Business
BASIC/XL opens a spool file when it executes the statement SEND SYSTEM
OUTPUT TO PRINTER or COPY ALL OUTPUT TO PRINTER. However, if HP Business
BASIC/XL then executes the statement SEND OUTPUT TO PRINTER, it does not
close the spool file and open another one.  Therefore, it sends system
output and PRINT statement output to the same spool file.

Device Specification Syntax (dev_spec).  Each output device specification
statement specifies an output device.  The output device is called
dev_spec (device specification) in the syntax specification for each
statement.  If dev_spec is not a legal output device, an error occurs and
HP Business BASIC/XL substitutes the standard list device for dev_spec.
The syntax for dev_spec follows.

Syntax 

     [[,MARGIN num_expr1], FIELD num_expr2]
dest [[,FIELD num_expr2], MARGIN num_expr1]

Parameters 

dest             Destination device.  See Table 6-8.

num_expr1        A numeric expression that evaluates to the number of
                 characters in an output line.  num_expr1 is rounded to
                 an integer, n1, which is called the margin.  It is best
                 thought of as the number of characters to reach the
                 right margin.  After an output statement prints n1 
                 characters on a line, it prints a carriage return and
                 line feed on that line.  Remaining characters are
                 printed on the next line.

                 The margin cannot be less than the output field width,
                 num_expr2.  If n1 is less than the field width, the
                 margin is set to the value of the field width.  If the
                 output file is an ASCII disk file with fixed-length
                 records, the margin cannot exceed the record length.
                 For these files, if n1 is greater than the record
                 length, the margin is set to the value of the record
                 length.

                 Default margin:  See Table 6-9.  Also, see the MARGIN
                 statement.

num_expr2        A numeric expression that evaluates to the number of
                 characters in an output field.  num_expr2 is rounded to
                 an integer, n2, called the output field width.

                 The output line begins with n1 DIV n2 output fields of
                 n2 characters each.  If n1 MOD n2 is not zero, the
                 output line ends with one output field of n1 MOD n2 
                 characters.  For example; a line with margin 75 and
                 output field width 20 begins with three 20-character
                 fields and ends with a 15-character field.

                 If the length of an output item exceeds the output field
                 width, it is still printed.

                 Default output field width:  See Table 6-10.


NOTE If HP Business BASIC/XL is running interactively, an output specification statement that specifies a margin has a side effect: it sets the terminal margin to n1.
Table 6-8 gives the possible destination values and the devices that they specify. Table 6-8. Destination Device Specifiers -------------------------------------------------------------------------------------------- | | | | Specifier | Destination | | | | -------------------------------------------------------------------------------------------- | | | | NULL | The system $NULL file. Usually used to discard | | | output. | | | | -------------------------------------------------------------------------------------------- | | | | DISPLAY | Terminal if HP Business BASIC/XL is running | | | interactively; equivalent to PRINTER if HP Business | | | BASIC/XL is running in a job stream. | | | | -------------------------------------------------------------------------------------------- | | | | PRINTER | The system printer, or if the system printer is a | | | spooled device, a spool file to be sent to the | | | system's printer. In the statements SEND SYSTEM | | | OUTPUT TO, and SEND OUTPUT TO, if you specify | | | dev_spec to be PRINTER, HP Business BASIC/XL uses | | | the file equation specified as your printer file. | | | This information is kept in the HP Business | | | BASIC/XL configuration file and can be changed by | | | running CNFGHPBB.Pub.Sys. | | | | -------------------------------------------------------------------------------------------- | | | | formal_designator | formal_designator has the same syntax as fname | | | described in "File Identification" in chapter 9. | | | Additionally, the formal_designator syntax includes | | [ { ,} ] | the quoted string literals "$STDLIST", "$NULL" and | | [ { .}FILESIZE[ =] fsize] | "*fname". The *fname syntax is used to reference | | [ { ,} ] | device files that have been previously defined | | | using file equations. The formal_designator for | | | dev_spec must reference a device or an ASCII or | | | BDATA file. If the file does not exist, HP | | | Business BASIC/XL creates an ASCII disk file with | | | fixed length 80 byte records. FILESIZE is an | | | optional parameter allowing specification of the | | | maximum number of records in the file. fsize is a | | | numeric expression that is evaluated and rounded to | | | an integer as required. | | | | -------------------------------------------------------------------------------------------- Table 6-9 gives the default margins for different types of destination devices. Table 6-9. Default Margins ----------------------------------------------------------------------------------------------- | | | | | Destination | Default Margin if Margin Was | Default Margin if Margin Was Not | | Device | Previously Specified for the | Previously Specified for the | | | Device | Device | | | | | ----------------------------------------------------------------------------------------------- | | | | | Terminal | Last specified margin. | 80 | | | | | ----------------------------------------------------------------------------------------------- | | | | | Line printer | Last specified margin. | 132 | | | | | ----------------------------------------------------------------------------------------------- | | | | | Other | 132 | 132 | | | | | ----------------------------------------------------------------------------------------------- Table 6-10 gives the default output field widths for different types of destination devices. Table 6-10. Default Output Field Widths ----------------------------------------------------------------------------------------------- | | | | | Destination | Default Output Field Width if | Default Output Field Width if | | Device | Output Field Width Was Previously | Output Field Width Was Not | | | Specified for the Device | Previously Specified for the | | | | Device | | | | | ----------------------------------------------------------------------------------------------- | | | | | Terminal | Last specified output field width. | 20 | | | | | ----------------------------------------------------------------------------------------------- | | | | | Line printer | Last specified output field width. | 20 | | | | | ----------------------------------------------------------------------------------------------- | | | | | Other | 20 | 20 | | | | | ----------------------------------------------------------------------------------------------- HP Business BASIC/XL opens an existing ASCII disk file in append mode; new records are appended to the existing records in the file. "Data Files", later in this chapter, has more information. If HP Business BASIC/XL tries to append an additional record to an ASCII disk file for which the end-of-file marker is at the physical end of file, an error message is displayed on the terminal. Redirect the output to DISPLAY at that point. A new file can then be specified to accept the redirected output. If you repeatedly encounter problems with the file size, use the FILESIZE option to create a larger file.


MPE/iX 5.0 Documentation