Re: Trouble reading bytes

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

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?

1. Use \\ instead of \ inside a string.

2. You should use "rb" and "wb" when you are
    writing non-text data, otherwise DOS/Windows will
    do strange things with numbers like 10, 13 and 26.
    (LF, CR and control-Z)

Regards,
    Rob Craig
    Rapid Deployment Software
    http://www.RapidEuphoria.com

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

Search



Quick Links

User menu

Not signed in.

Misc Menu