Using STRING to Format Data
The STRING function has the following form:
S = STRING(Expression1, ..., Expressionn)
It converts its parameters to characters, returning the result as a string expression. It is identical in function to the PRINT procedure, except that its output is placed into a string rather than being output to the terminal. As with PRINT, the FORMAT keyword can be used to explicitly specify the desired format. See the discussions of free format and explicitly formatted input/output (Free Format I/O) for details of data formatting. For more information on the STRING function, see "STRING" (IDL Reference Guide).
As a simple example, the following IDL statements:
; Produce a string array. A = STRING(FORMAT='("The values are:", /, (I))', INDGEN(5)) ; Show its structure. HELP, A ; Print the result. FOR I = 0, (N_ELEMENTS(A)-1) DO PRINT, A[I]
produce the following output:
Note
When you use vector, TrueType, and some device fonts, text strings can include embedded formatting commands that facilitate subscripting, superscripting, and equation formatting. See Embedded Formatting Commands (IDL Reference Guide).
Reading Data from Strings
The READS procedure performs formatted input from a string variable and writes the results into one or more output variables. This procedure differs from the READ procedure only in that the input comes from memory instead of a file.
This routine is useful when you need to examine the format of a data file before reading the information it contains. Each line of the file can be read into a string using READF. Then the components of that line can be read into variables using READS.
See the description of "READS" (IDL Reference Guide) for more details.