AtEndOfFile - Maple Help

FileTools

 AtEndOfFile
 determine if the current position of a file is at the end

 Calling Sequence AtEndOfFile(file)

Parameters

 file - filename or file descriptor

Description

 • The AtEndOfFile(file) command returns true if and only if the end of a STREAM file has been reached during a read operation. Otherwise, AtEndOfFile(file) returns false.
 • The end of file must actually have been encountered. For example, requesting  Read to read 20 bytes when only 19 remain in the file results in a subsequent AtEndOfFile call returning true. When the ReadLine function reads the last line of a file, it does not encounter the end of file; the next call to ReadLine reads the end of file.
 • If file does not refer to an open file, AtEndOfFile raises an error.

Examples

 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{Open}\right]\left(\mathrm{testfile}\right):$
 > $\mathrm{FileTools}\left[\mathrm{AtEndOfFile}\right]\left(\mathrm{testfile}\right)$
 ${\mathrm{false}}$ (1)
 > $\mathrm{FileTools}\left[\mathrm{Position}\right]\left(\mathrm{testfile},\mathrm{\infty }\right):$
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadCharacter}\right]\left(\mathrm{testfile}\right):$
 > $\mathrm{FileTools}\left[\mathrm{AtEndOfFile}\right]\left(\mathrm{testfile}\right)$
 ${\mathrm{true}}$ (2)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{Close}\right]\left(\mathrm{testfile}\right):$