FileTools[Text] - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

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

FileTools[Text]

 ReadString
 read a string from a file

 Calling Sequence ReadString(file)

Parameters

 file - file descriptor or filename

Description

 • The ReadString(file) command reads a whitespace delimited string from file.
 • 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 cannot be opened.
 • If the end of the file has been reached, ReadString returns NULL. To determine if the end of file has been reached, use AtEndOfFile.

Examples

 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{WriteString}\right]\left("testfile","This is a test\n"\right)$
 ${15}$ (1)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{Close}\right]\left("testfile"\right):$
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadString}\right]\left("testfile"\right)$
 ${"This"}$ (2)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadString}\right]\left("testfile"\right)$
 ${"is"}$ (3)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadString}\right]\left("testfile"\right)$
 ${"a"}$ (4)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadString}\right]\left("testfile"\right)$
 ${"test"}$ (5)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadString}\right]\left("testfile"\right)$

 See Also