PRINT Procedures
Perform output of ASCII data:
PRINT performs output to the standard output stream (file unit –1).
PRINTF requires the output file unit to be specified.
note | PRINT outputs a 2D array as if it were an image, i.e., the first dimension corresponds to the columns. Use PM to output a 2D array in standard matrix format, i.e., where the first dimension corresponds to the rows. |
Usage
PRINT, expr1, ... , exprn
PRINTF, unit, expr1, ... , exprn
Input Parameters
unit — The file unit to which the output will be sent.
expri — The expressions to be output.
Keywords
Format — Allows the format of the output to be specified in precise detail, using a FORTRAN-style specification. FORTRAN-style formats are described in the PV‑WAVE Programmer’s Guide.
If the Format keyword is not present, PV-WAVE uses its default rules for formatting the output. These rules are described in the PV‑WAVE Programmer’s Guide.
Example
In this example, PRINTF is used to write 10 integers to a file. The integers are then read from the file and displayed using the PRINT procedure. The Format keyword is used with the PRINT procedure to place one space after each integer as it is written to the screen.
; Create a 10-element integer vector that is initialized to the
; values of its one-dimensional subscripts.
nums = INDGEN(10)
; Open the printex.dat file for writing.
OPENW, unit, 'printex.dat', /Get_Lun
; Write the integers in nums to the file.
PRINTF, unit, nums
; Rewind the file to the beginning.
POINT_LUN, unit, 0
; Create a 10-element integer vector.
n = INTARR(10)
; Read the contents of printex.dat into n.
READF, unit, n
; Display the formatted contents of variable n.
PRINT, n, Format = '(10(i1, 1x))'
; PV-WAVE prints: 0 1 2 3 4 5 6 7 8 9
; Close the file and free the file unit number.
FREE_LUN, unit
See Also