Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25535] Re: Q: FastBinaryFiles-package: how to detect EndOfFile?
  • From: tgayley at wolfram.com (Todd Gayley)
  • Date: Sat, 7 Oct 2000 03:35:40 -0400 (EDT)
  • Organization: Wolfram Research, Inc.
  • References: <8r1a0u$i1j@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

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

>Hello,
>
>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 ]?

Claudius,

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];
		result
	]

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

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