SUMMARY: formatted printing of structures [message #464] |
Tue, 28 July 1992 13:33 |
knight
Messages: 37 Registered: January 1992
|
Member |
|
|
In an earlier posting (~10 Jul) I considered the inconsistent results of
printing elements of a structure. This posting summarizes the results,
including a reply from RSI.
The problem is exemplified by the following:
IDL> t={a:0,b:1,c:2}
IDL> print,format='(3f10.2)',t ; BAD---NOT ON ONE LINE
0.00
1.00
2.00
IDL> print,string(format='(3f10.2)',t) ; BAD---f11.2 FOR 2ND AND 3RD TAGS
0.00 1.00 2.00
IDL> print,format='(3f10.2,$)',t & print ; OK---WHAT I WANTED
0.00 1.00 2.00
In brief, this behavior will be corrected in the next version (> 2.3.2) so
that all three statements produce the same results. The explanation from
RSI is the following.
> When printing a variables, IDL decomposes each structure into its
> non-structure components, and then prints all of the components
> according to the format statement or the default formatting.
> There was a problem with the way IDL decomposed the structure into
> its components. Instead of treating all the components as part
> of the same variable, it treated them as separate variables. This
> caused the first example shown above to produce three separate lines
> rather than a single line.
> The IDL routine STRING also uses the same method to deal with variables,
> so the same problem caused STRING to create a string array of three
> elements rather than one string. When the elements of the string array
> are printed they are padded with a single space which explains the output
> from the second example above. This can be seen clearly by using the
> following IDL statement:
> help, string(format='(3f10.2)',t)
> The problem with the decomposition of structure variables has been fixed,
> and will be available in the next version of IDL after IDL V 2.3.2.
Thanks to the people who contributed the solution of using the $ format.
Fred
--
=Fred Knight (knight@ll.mit.edu) (617) 981-2027
C-483\\MIT Lincoln Laboratory\\244 Wood Street\\Lexington, MA 02173
|
|
|