11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

166 • Chapter 4: Input and OutputDetecting the End of a FileThe feof command determines whether you have reached the end of afile. Only use the feof command on files that you have opened as STREAMsimplicitly or explicitly via fopen. Call feof in the following manner.feof( fileIdentifier )The fileIdentifier is the name or descriptor of the file to query. If you givea filename, and that file is not yet open, Maple opens it in READ modewith type BINARY.The feof command returns true if and only if you have reached theend of the file during the most recent readline, readbytes, or fscanfoperation. Otherwise, feof returns false. This means that if 20 bytesremain in a file and you use readbytes to read these 20 bytes, then feofstill returns false. You encounter the end-of-file only after you attemptanother read.Determining File StatusThe iostatus command returns detailed information about all the filescurrently in use. Call the iostatus command with the following syntax.iostatus()The iostatus command returns a list. The list contains the followingelements:iostatus()[1] The number of files that the Maple I/O library is currentlyusing.iostatus()[2] The number of active nested read commands (when readreads a file, which itself contains a read statement).iostatus()[3] The upper bound on iostatus()[1] + iostatus()[2]that the underlying operating system imposes.iostatus()[n] for n > 3. A list giving information about a file currentlyin use by the Maple I/O library.When n > 3, the lists that iostatus()[n] return each contain thefollowing elements:iostatus()[n][1] The file descriptor which fopen or open returned.iostatus()[n][2] The filename.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!