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
|
|
|