11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4.5 Input Commands • 167iostatus()[n][3] The file kind (STREAM, RAW, or DIRECT).iostatus()[n][4] The file pointer or file descriptor that the underlyingoperating system uses. The pointer is in the form FP=integer orFD=integer.iostatus()[n][5] The file mode (READ or WRITE).iostatus()[n][6] The file type (TEXT or BINARY).Removing FilesMany files are solely for temporary use. Because you do not need thesefiles in future Maple sessions, remove them. Use the fremove commandto do this.fremove( fileIdentifier )The fileIdentifier is the name or descriptor of the file to remove. If thefile is open, Maple closes it before removing it. If the file does not exist,Maple generates an error.To remove a file regardless of whether it exists, use a try/catch statementto trap the error that fremove might create.> try fremove("myfile.txt") catch: end try:4.5 Input CommandsReading Text Lines from a FileThe readline command reads a single line of text from a file. Charactersare read up to and including a new line. The readline command thendiscards the new line character, and returns the line of characters as aMaple string. If readline cannot read a whole line from the file, then itreturns 0 instead of a string.Call the readline command by using the following syntax.readline( fileIdentifier )The fileIdentifier is the name or descriptor of the file to read. Forcompatibility with earlier versions of Maple, you can omit the fileIdentifier,in which case Maple uses default. Thus readline() andreadline(default) are equivalent.

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

Saved successfully!

Ooh no, something went wrong!