Re: Trouble reading bytes

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

On Fri, Aug 01, 2003 at 01:05:14PM +1000, Derek Parnell wrote:
<Snip>
> 
> constant data = {{0,0,0,0,0},
>            {1,1,1,1,1},
>            {2,2,2,2,2},
>            {3,3,3,3,3}} 
> integer fn
> 
> fn = open("c:\\file.dat", "w")
>      for i = 1 to length(data) do
>          print(fn, data[i])
>          puts(fn,' ') -- needed to seperate the sequences!
>          -- I suspect this is a bug in get() that requires this.

Technically its not a bug. get() wants whitespace to make clear that those
values are seperate.

>      end for
> close(fn)
> 
> fn = open("c:\\file.dat", "r")
> sequence res
> res = get(fn)
> while res[1] != GET_EOF do
>     ? res[2]
>     res = get(fn)
> end while
> close(fn)
> 
> -- 
> Derek
> 

Here is a version that is simpler.

 constant data = {{0,0,0,0,0},
            {1,1,1,1,1},
            {2,2,2,2,2},
            {3,3,3,3,3}} 
 integer fn
 
 fn = open("c:\\file.dat", "w")
 print(fn, data)
 close(fn)
 
 fn = open("c:\\file.dat", "r")
 sequence res
 res = get(fn)
 if res[1] = GET_SUCCESS then
    --we have the data
 else
    --error
 end while
 close(fn)

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

jbrown

-- 
 /"\  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