CountLines - Maple Help

FileTools[Text]

 CountLines
 count the number of lines from the current file position to the end of the file

 Calling Sequence CountLines(file)

Parameters

 file - file descriptor or filename

Description

 • The CountLines(file) command counts the number of lines from the current position in file to the end of file.
 • A line is defined to be zero or more characters delimited by the current file position, a new line character, and the end of file.  There is one exception to this definition: if the last character in the file is a newline, then the null string (zero characters) between this newline and the end of file is not considered a line. This definition is consistent with the behavior of ReadLine and readline.
 • An error is raised if file is not a valid descriptor or if it is the name of a file that does not exist.

Examples

 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{WriteString}\right]\left("foo","1\n2\n3\n4\n5"\right)$
 ${9}$ (1)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{Close}\right]\left("foo"\right):$
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{CountLines}\right]\left("foo"\right)$
 ${5}$ (2)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadLine}\right]\left("foo"\right)$
 ${"1"}$ (3)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{CountLines}\right]\left("foo"\right)$
 ${4}$ (4)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadLine}\right]\left("foo"\right)$
 ${"2"}$ (5)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{CountLines}\right]\left("foo"\right)$
 ${3}$ (6)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadLine}\right]\left("foo"\right)$
 ${"3"}$ (7)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{CountLines}\right]\left("foo"\right)$
 ${2}$ (8)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadLine}\right]\left("foo"\right)$
 ${"4"}$ (9)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{CountLines}\right]\left("foo"\right)$
 ${1}$ (10)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadLine}\right]\left("foo"\right)$
 ${"5"}$ (11)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{CountLines}\right]\left("foo"\right)$
 ${0}$ (12)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{Close}\right]\left("foo"\right):$
 > $\mathrm{FileTools}\left[\mathrm{Remove}\right]\left("foo"\right):$