FileTools[Text] - Maple Programming Help

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

FileTools[Text]

 read a single character from a file

Parameters

 file - file descriptor or filename

Description

 • The ReadCharacter(file) command reads a single character from file.  The character is returned as a string of length $1$.
 • If file is the name of a file that has not been opened, Maple attempts to open the file before reading the character.
 • An error is raised if file is not a valid descriptor or if it is the name of a file that does not exists.
 • If the end of the file has been reached, ReadCharacter returns NULL.

Examples

 > $\mathrm{FileTools}[\mathrm{Text}][\mathrm{WriteString}]\left("file","123"\right)$
 ${3}$ (1)
 > $\mathrm{FileTools}[\mathrm{Text}][\mathrm{Close}]\left("file"\right):$
 > $\mathrm{FileTools}[\mathrm{Text}][\mathrm{ReadCharacter}]\left("file"\right)$
 ${"1"}$ (2)
 > $\mathrm{FileTools}[\mathrm{Text}][\mathrm{ReadCharacter}]\left("file"\right)$
 ${"2"}$ (3)
 > $\mathrm{FileTools}[\mathrm{Text}][\mathrm{ReadCharacter}]\left("file"\right)$
 ${"3"}$ (4)
 > $\mathrm{FileTools}[\mathrm{Text}][\mathrm{ReadCharacter}]\left("file"\right)$