Question: A user has asked us how to write data from a structure to a file using printf. without carriage returns being added to the middle of a record. Answer: If you run the following commands, it print the structure to a file with carriage returns: IDL> A = {star, name:'Hello There!', ra:2.0, dec:3.0, inten:FLTARR(12)+4.0} IDL> openw, 1, "test_struct_output.txt" IDL> printf, 1, A IDL> free_lun, 1 On way to workaround this issue is to use the FORMAT keyword to specify that all the elements within a structure are written to the same line. For example: IDL> A = {star, name:'Hello There!', ra:2.0, dec:3.0, inten:FLTARR(12)+4.0} IDL> printf, 1, A, FORMAT='(50A)' IDL> free_lun, 1 Where the in the "(50A)' format, the '50' should be any number that is greater than the number of elements in the structure David S. -HGS.
|