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

Home » Public Forums » archive » Re: writeu, printf, readu/f 2 file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: writeu, printf, readu/f 2 file [message #24261 is a reply to message #24136] Mon, 19 March 2001 07:45 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
Craig Markwardt wrote:
>
> Without delving into too much detail about your specific program, I
> can say that you should pay a lot more attention to your output
> formatting. Don't assume, simply because you print it out one way, it
> can be read the same way. For example:
>
> IDL> openw, 50, 'test.dat'
> IDL> printf, 50, 1, '2 3', 4
> IDL> close, 50
> IDL> openr, 50, 'test.dat'
> IDL> a = 0 & b = '' & c = 0
> IDL> readf, 50, a, b, c
> % READF: End of file encountered. Unit: 50
> File: test.dat
> % Execution halted at: $MAIN$
>
> Hmmm, why did this fail? Well, the string B is very greedy and it
> consumes everything to the end of the line, including the "4".
>
> Mixing formatted and unformatted data in a file can be tricky. The
> problem is that when you read formatted data the file pointer can
> advance unpredictably. Better to read and write the data
> intermediately to a string buffer.
>
> Craig
>

... or use a byte array to represent strings in a binary file. I have
a little utility program available that will convert strings (or
string arrays) to byte arrays. To go back, you can simply use
String(thearray). The program is here:

http://www.mpimet.mpg.de/~schultz.martin/idl/html/src/martin _schultz/str2byte.pro

Cheers,
Martin

--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 41173-298 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[Message index]
 
Read Message
Read Message
Previous Topic: BETTER FONTS
Next Topic: Writing large [x,x,x,x] files

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

Current Time: Tue Dec 02 22:16:57 PST 2025

Total time taken to generate the page: 0.64039 seconds