Writes to standard
output.
Syntax
The syntax of the PRINT statement can take one of two forms:
Formatted and list-directed syntax:
PRINT format [, output-list ] |
Namelist-directed
syntax:
- format
is one of the following:
An asterisk (*), specifying list-directed I/O.
The label of a FORMAT statement containing the format specification.
An integer variable that has been assigned the label
of a FORMAT statement.
An embedded format
specification.
- name
is the name of
a namelist group, as previously defined by a NAMELIST statement . Using the namelist-directed syntax,
the PRINT statement sends data in the namelist group to
standard output. To direct output to a connected file, you must
use the WRITE statement and include the NML= specifier.
- output-list
is a comma-separated list of data items for output.
The data items can include expressions and implied-DO lists.
Description
The PRINT statement transfers data from memory to standard
output. (Unit 6 is preconnected to the HP-UX standard output.) The PRINT statement can be used to perform formatted, list-directed,
and namelist-directed I/O only.
To direct output to a connected file, use the WRITE statement.
Examples
The examples in this section illustrate different uses of
the PRINT statement.
Formatted output
The following
statement writes the contents of the variables num and des to standard output, using the format specification
in the FORMAT statement at label 10:
List-directed output
The following
statement uses list-directed formatting to print the literal string x= and the value of the variable x:
Embedded format specification
The following
statement uses an embedded format specification to print the same
output:
PRINT '(A2, F8.2)', 'x=', x |
Namelist-directed output
The following
statement prints all variables in the namelist group coord, using namelist-directed formatting:
Related statements
FORMAT and WRITE
Related concepts
For related information, see the following: