Mixing ASCII and Binary in files [message #22553] |
Wed, 15 November 2000 00:00  |
Ben Tupper
Messages: 186 Registered: August 1999
|
Senior Member |
|
|
Hello,
Thank you for all for the very interesting responses regarding my Julian
Day number query.
I have a question regarding mixing ASCII data (as a header) with binary
data (as data following the header). This is a desirable format for our
purposes for a number of reasons. I have come across such files
generated in the DOS environment from Sea-Bird Electronics devices.
I am able to read and write such files in MacOS using IDL without
difficulty; I am unable to do the same in Windows.
From within IDL, is it possible to write such a file so that it is
readable across all platforms? If so, how?
Thanks
Ben
--
Ben Tupper
Bigelow Laboratory for Ocean Sciences
180 McKown Point Rd.
W. Boothbay Harbor, ME 04575
btupper@bigelow.org
|
|
|
|
Re: Mixing ASCII and Binary in files [message #22653 is a reply to message #22553] |
Tue, 28 November 2000 00:00  |
Ben Tupper
Messages: 186 Registered: August 1999
|
Senior Member |
|
|
Hello,
I hate to post a follow-up so long after the original post first appeared.
I was the original poster-person (posterizer, posterer?) I seem to be
behind the eight ball a wee-bit. I haven't had the chance to get back to
this until just now.
To write the file:
;first write the header
OpenW, U, FileName, /NoAutoMode, /Get_LUN ;open as a text file
PrintF, U, ASCIIDataHERE, ..... my stuff included a multi-field structure
with tag names
Free_LUN, U ;close the file
;now the binary data
OPENU, U, FileName, /NoAutoMode, /Binary, /Append, /Get_LUN ;open
as binary
WriteU, U, BinaryDataHERE ;append the data
Free_LUN, U ;close the file
To read the above file:
;first read the header
OpenR, U, FileName, /NoAutoMode, /Get_LUN ;open as text
file
ReadF, U, ASCIIdataHere, ....
F = FSTAT(U) ;capture the file state (in particular the
current pointer position)
Free_LUN, U
;now read the binary data
OpenR, U, FileName, /NoAutoMode, /Binary, /Get_LUN ;open as binary
Point_LUN, U, F.Cur_Ptr ;advance the file pointer to
end of header
ReadU, U, BinaryDataHere
Free_LUN, U
It seems to work just fine now. A simple series of steps, soon to be
obselete when IDL 5.4 arrives in time for the holidays.
Now, I wonder if it's too late to send in my absentee ballot?
Ben
--
Ben Tupper
248 Lower Round Pond Road
POB 106
Bristol, ME 04539
Tel: (207) 563-1048
Email: PemaquidRiver@tidewater.net
|
|
|