Yasmin
Yasmin

Reputation: 951

How to get number of lines of file in prolog?

I know that there is a predicate :

line_count(Stream, LineCount)

but this predicate get how many numbers you are reading or writing ?, I need to append a file and before appending it, I need to check the number of the lines that have been inserted, So Is there any way I can do it with ?

Thanks,

Upvotes: 1

Views: 1576

Answers (1)

NotAUser
NotAUser

Reputation: 1456

If Stream is open for writing then it's the lines that have been written. If it's open for reading it's the lines that are read.

You can open the file and read it. Then save the lines and after you open it again for writing you can count the lines you have written.

http://sicstus.sics.se/sicstus/docs/4.1.0/html/sicstus/mpg_002dref_002dline_005fcount.html

Upvotes: 1

Related Questions