MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Q: FastBinaryFiles-package: how to detect EndOfFile?

On 29 Sep 2000 01:40:46 -0400, Claudius =?iso-8859-1?Q?Schn=F6rr?=
<schnoerr at> wrote:

>is it possible to test whether the LinkInputStream is at the EndOfFile
>before trying to read further with ReadListBinary?
>Or is there a way to get the LinkObject used in the package to test it by
>LinkReadyQ[ link ]?


When the LinkInputStream is at the end of the file, any further reads
will immediately return EndOfFile. Here is a function that uses that
fact to determine whether the stream is at EOF:

AtEndOfFileQ[s_LinkInputStream] :=
	Module[{pos, result},
		pos = StreamPosition[s];
		result = ReadBinary[s, Byte] === EndOfFile;
		SetStreamPosition[s, pos];

The LinkObject used by the package is returned from the
Install["binary"] line that you use to launch the program. This
LinkObject won't be of any use in determining anything about the state
of the LinkInputStream, though. LinkReadyQ will always return False.


Todd Gayley
Wolfram Research

  • Prev by Date: Complex Function Plot
  • Next by Date: Re: Graphing, Symbolic Manipulation, and Regressions
  • Previous by thread: Complex Function Plot
  • Next by thread: advanced keystroke remapping