Re: Trouble reading bytes

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Fri, Aug 01, 2003 at 12:36:18AM +0000, Al Getz wrote:
> 
> 
> dstanger at belco.bc.ca wrote:
> > Im using this method to write the contents of a sequence to a file:
> > 
> > data = {{0,0,0,0,0},
> >            {1,1,1,1,1},
> >            {2,2,2,2,2},
> >            {3,3,3,3,3}} 
> > 
> > fn = open("c:\file.dat", "w")
> >      for i = 1 to length(data) do
> >          puts(fn, data[i])
> >      end for
> > close(fn)
> > 
> > But when I read it back from the file into a sequence using getc() 
> > sometimes a -1 is returned rather than the number that I originally 
> > saved. Where am I going wrong?
> > 
> > Thanks,
> > David 
> > 
> 
> Dont you use 'get()' for that?
> 
> Take care,
> Al
> 

No. He is using puts() to output the data, not print() or ?().

-1 means it has reached the end of file. My guess: use mode "wb" instead of
"w" to write the file, and use mode "rb" to read it back (since the data
appears to be binary as opposed to text).

jbrown

> 
> 
> TOPICA - Start your own email discussion group. FREE!
> 
> 

-- 
 /"\  ASCII ribbon              | http://www.geocities.com/jbrown1050/
 \ /  campain against           | Linux User:190064
  X   HTML in e-mail and        | Linux Machine:84163
 /*\  news, and unneeded MIME   | http://verify.stanford.edu/evote.html

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu