Re: Trouble reading bytes
- Posted by 1evan at sbcglobal.net
Aug 01, 2003
From the docs:
Comments: When you output a sequence of bytes it must not have any
(sub)sequences within it. It must be a sequence of atoms only.
(Typically a string of ASCII codes).
Avoid outputting 0's to the screen or to standard output. Your output
may get truncated.
data is a sequence of 5 subsequences.
Something like:
sequence data
object fn
data = {{0,0,0,0,0},
{1,1,1,1,1},
{2,2,2,2,2},
{3,3,3,3,3}}
fn = open("file.dat", "w")
for i = 1 to length(data) do
for j = 1 to length(data[i]) do
printf(fn,"%d",data[i][j])
end for
end for
close(fn)
will get you closer to what you are looking for.
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
>
> --^^---------------------------------------------------------------
> This email was sent to: 1evan at sbcglobal.net
>
>
> TOPICA - Start your own email discussion group. FREE!
>
|
Not Categorized, Please Help
|
|