PRINT/PRINTF
Syntax | Arguments | Keywords | Examples | Version History | See Also
The two PRINT procedures perform formatted output. PRINT performs output to the standard output stream (IDL file unit -1), while PRINTF requires a file unit to be explicitly specified.
Note
IDL uses the standard I/O function sprintf to do its formatting. Different platforms implement this function in different ways, which may lead to slight inconsistencies in the appearance of the output. In most cases, specifying an explicit output format via the FORMAT keyword allows better control over the appearance than simply using the default formatting.
Format Compatibility
If the FORMAT keyword is not present and PRINT is called with more than one argument, and the first argument is a scalar string starting with the characters "$(", this initial argument is taken to be the format specification, just as if it had been specified via the FORMAT keyword. This feature is maintained for compatibility with version 1 of VMS IDL.
Syntax
PRINT [, Expr1, ..., Exprn]
PRINTF [, Unit, Expr1, ..., Exprn]
Keywords: [, AM_PM=[string, string]] [, DAYS_OF_WEEK=string_array{7 names}] [, FORMAT=value] [, MONTHS=string_array{12 names}] [, /STDIO_NON_FINITE]
Arguments
Unit
For PRINTF, Unit specifies the file unit to which the output is sent.
Expri
The expressions to be output.
Keywords
AM_PM
Supplies a string array of 2 names to be used for the names of the AM and PM string when processing explicitly formatted dates (CAPA, CApA, and CapA format codes) with the FORMAT keyword.
DAYS_OF_WEEK
Supplies a string array of 7 names to be used for the names of the days of the week when processing explicitly formatted dates (CDWA, CDwA, and CdwA format codes) with the FORMAT keyword.
FORMAT
If FORMAT is not specified, IDL uses its default rules for formatting the output. FORMAT allows the format of the output to be specified in precise detail, using a FORTRAN-style specification. See Using Explicitly Formatted Input/Output (Application Programming).
MONTHS
Supplies a string array of 12 names to be used for the names of the months when processing explicitly formatted dates (CMOA, CMoA, and CmoA format codes) with the FORMAT keyword.
STDIO_NON_FINITE
Set this keyword to allow the writing of data files readable by C or FORTRAN programs on a given platform; it is otherwise unnecessary.The various systems supported by IDL differ widely in the representation used for non-finite floating point values (i.e., NaN and Infinity). Consider that the following are all possible representations for NaN on at least one IDL platform:
And the following are considered to be Infinity:
On input, IDL can recognize any of these, but on output, it uses the same standard representation on all platforms. This promotes cross-platform consistency. To cause IDL to use the system C library sprintf() function to format such values, yielding the native representation for that platform, set the STDIO_NON_FINITE keyword.
Examples
To print the string "IDL is fun." enter the command:
To print the same message to the open file associated with file unit number 2, use the command:
Version History
For information on obsolete keywords, see IDL API History.
See Also
ANNOTATE, MESSAGE, STRING, WRITEU, XYOUTS