read a line from a file - Maple Help

Home : Support : Online Help : Programming : Input and Output : File Manipulation : FileTools : FileTools/Text/ReadLine

Parameters

 file - file descriptor or filename

Description

 • The ReadLine(file) command reads a string containing all the characters from the current file position to the first newline character or the end of file.  The characters are returned as a string.
 • If the current file position is the end of the file, a call to ReadLine returns NULL, but ReadLine does not automatically close file. This behavior is different from readline.

Examples

 > ${\mathrm{FileTools}[\mathrm{Text}]}_{\mathrm{WriteLine}}\left("testfile","This is a test"\right)$
 ${15}$ (1)
 > ${\mathrm{FileTools}[\mathrm{Text}]}_{\mathrm{WriteLine}}\left("testfile","This is also a test"\right)$
 ${20}$ (2)
 > ${\mathrm{FileTools}[\mathrm{Text}]}_{\mathrm{Close}}\left("testfile"\right)$
 > ${\mathrm{FileTools}[\mathrm{Text}]}_{\mathrm{ReadLine}}\left("testfile"\right)$
 ${"This is a test"}$ (3)
 > ${\mathrm{FileTools}[\mathrm{Text}]}_{\mathrm{ReadLine}}\left("testfile"\right)$
 ${"This is also a test"}$ (4)
 > ${\mathrm{FileTools}[\mathrm{Text}]}_{\mathrm{ReadLine}}\left("testfile"\right)$
 > $\mathrm{FileTools}[\mathrm{Remove}]\left("testfile"\right)$