From: Jason Karney
Subject: reading a binary file
Date: 
Message-ID: <3624C59C.CC13B7E7@netgenics.com>
--------------0BB26168AB94EA8B708A0D39
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

 Hi,

I originally posted this on comp.lang.scheme, but thought that perhaps I'd get a
response faster here, since there is always more activity on this newsgroup.

> I am trying to read in a binary file using STk. (A Java class file, actually.) I
> am using read-char (which I convert to an integer), until eof-object? returns
> true.
>
> For some reason, I always get eof after 61 characters are read in, and I
> wondered if it has to do with the value of eof-object.
>
> Any ideas or suggestions are appreciated. Thanks.
>
--
Jason Karney    <-  Advanced Technology Scientist
NetGenics, Inc.             [·····@netgenics.com]
[STOP] Okay, you were there yesterday, but
       Where do you want to go tomorrow?


--------------0BB26168AB94EA8B708A0D39
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
&nbsp;Hi,

<P>I originally posted this on comp.lang.scheme, but thought that perhaps
I'd get a response faster here, since there is always more activity on
this newsgroup.
<BLOCKQUOTE TYPE=CITE>
<PRE>I am trying to read in a binary file using STk. (A Java class file, actually.) I
am using read-char (which I convert to an integer), until eof-object? returns
true.

For some reason, I always get eof after 61 characters are read in, and I
wondered if it has to do with the value of eof-object.

Any ideas or suggestions are appreciated. Thanks.</PRE>
</BLOCKQUOTE>


<P>--
<BR>Jason Karney&nbsp;&nbsp;&nbsp; &lt;-&nbsp; Advanced Technology Scientist
<BR>NetGenics, Inc.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
[·····@netgenics.com]
<BR>[STOP] Okay, you were there yesterday, but
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Where do you want to go tomorrow?
<BR>&nbsp;</HTML>

--------------0BB26168AB94EA8B708A0D39--
From: Steve Gonedes
Subject: Re: reading a binary file
Date: 
Message-ID: <m2vhlmdbia.fsf@KludgeUnix.com>
Jason Karney <·····@netgenics.com> writes:


< Content-type: text/plain ; charset = us-ascii
<
<  Hi,
<
< I originally posted this on comp.lang.scheme, but thought that
< perhaps I'd get a response faster here, since there is always more
< activity on this newsgroup.
<
< > I am trying to read in a binary file using STk. (A Java class
< > file, actually.) I am using read-char (which I convert to an
< > integer), until eof-object? returns true.
< >
< > For some reason, I always get eof after 61 characters are read in, and I
< > wondered if it has to do with the value of eof-object.
< >
< > Any ideas or suggestions are appreciated. Thanks.

My guess is that you just hit the end of a string. I was just parsing
a file where the sizes of each string was known, yet every string
still ended in a zero.

In any case, when parsing binary files you may not be able to reliably
use eof-object? to detect the true end of the file. Maybe you'll have
luck iterating `file size' times. In CL it could possibly look like,

(with-open-file 
    (input "binary-file.dat" :direction :input :element-type 'character)
  (loop repeat (file-length input) do
        (let ((byte (char-code (read-char input))))
          ...))).

Maybe you're scheme has a method for binary file input. Something like
a read-byte would probably be more efficient that converting
characters to bytes plus easier to understand.