comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Writing a structure containing empty strings
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Writing a structure containing empty strings [message #49607] Mon, 07 August 2006 08:12
news.verizon.net is currently offline  news.verizon.net
Messages: 47
Registered: August 2003
Member
This message and the next one address long-standing problems I've had
with IDL software to handle the FITS data format used in astronomy.

When writing an IDL structure, str, to FITS format, the following
simple code *almost* works.

openw,lun, 'output.dat',/get_lun
writeu,lun, str
free_lun, lun

The only problem occurs if one of the structure tags contains an empty
string. What I want is for IDL to write a zeroed byte (0b), but IDL
simply ignores the tag and doesn't write anything. Note that IDL
does understand 0b as the byte representation of an empty string:

IDL> print,strlen(string(0b))
0
IDL> print,byte('')
0

but it simply skip over an empty string when performing I/O. So my
first thought is to convert the string tags to bytes, but this has two
problems: (1) one can't directly change the data type of a structure
tag and (2) converting a string array to byte forces everything to a
fixed length. So right now, I loop over every element and every tag
of the structure and write it to disk:, if it is a string tag I test
for the presence of an empty string, and then further loop over the
string array to convert every element to a byte array before writing to
disk. So simple code that *almost* works, requires a major revision
to completely work. Or am I missing a simpler solution?
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: nearest number
Next Topic: Re: nearest number

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:21:57 PDT 2025

Total time taken to generate the page: 0.00485 seconds