CountLines - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


FileTools[Text]

  

CountLines

  

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

 

Calling Sequence

Parameters

Description

Examples

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

FileToolsTextWriteStringfoo,1\n2\n3\n4\n5

9

(1)

FileToolsTextClosefoo:

FileToolsTextCountLinesfoo

5

(2)

FileToolsTextReadLinefoo

1

(3)

FileToolsTextCountLinesfoo

4

(4)

FileToolsTextReadLinefoo

2

(5)

FileToolsTextCountLinesfoo

3

(6)

FileToolsTextReadLinefoo

3

(7)

FileToolsTextCountLinesfoo

2

(8)

FileToolsTextReadLinefoo

4

(9)

FileToolsTextCountLinesfoo

1

(10)

FileToolsTextReadLinefoo

5

(11)

FileToolsTextCountLinesfoo

0

(12)

FileToolsTextClosefoo:

FileToolsRemovefoo:

See Also

FileTools[Position]

FileTools[Remove]

FileTools[Text]

FileTools[Text][Close]

FileTools[Text][CountCharacters]

FileTools[Text][ReadLine]

FileTools[Text][WriteString]