count the number of lines from the current file position to the end of the file - Maple Help

Online Help

All Products    Maple    MapleSim


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

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

FileTools[Text]WriteStringfoo,1 2 3 4 5

9

(1)

FileTools[Text]Closefoo:

FileTools[Text]CountLinesfoo

5

(2)

FileTools[Text]ReadLinefoo

1

(3)

FileTools[Text]CountLinesfoo

4

(4)

FileTools[Text]ReadLinefoo

2

(5)

FileTools[Text]CountLinesfoo

3

(6)

FileTools[Text]ReadLinefoo

3

(7)

FileTools[Text]CountLinesfoo

2

(8)

FileTools[Text]ReadLinefoo

4

(9)

FileTools[Text]CountLinesfoo

1

(10)

FileTools[Text]ReadLinefoo

5

(11)

FileTools[Text]CountLinesfoo

0

(12)

FileTools[Text]Closefoo:

FileTools[Remove]foo:

See Also

FileTools[Position], FileTools[Remove], FileTools[Text], FileTools[Text][Close], FileTools[Text][CountCharacters], FileTools[Text][ReadLine], FileTools[Text][WriteString]


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam