Make your own free website on Tripod.com
3.2.37. LINES([streamid])

Returns the number of complete lines remaining in the named file
stream. A complete line is not really as complete as the name
might indicate; a complete line is zero or more characters,
followed by an End-Of-Line (EOL) marker. So, if you have read half
a line already, you still have a “complete” line left. Note that
it is not defined what to do with a half-finished line at the end
of a file. Some interpreters might interpret the End-Of-File as an
implicit EOL mark too, while others might not.

The format and contents of the stream streamid is system and
implementation dependent. If omitted, the default input stream
will be used.

The standard says that if it is impossible (or maybe just
difficult) to accurately count the remaining lines in a stream,
LINES() can return 0 for no more lines, and 1 for more lines. This
probably applies for all transient streams, as the interpreter can
not reposition in these files, and can therefore not count the
number of remaining lines. It can also apply for persistent files,
if the operation of counting the lines left in the file is very
time-consuming.

As a result, defensive programming indicates that you can safely
only assume that this function will return either 0 or a non-zero
result. If you want to use the non-zero result to more than just
an indicator on whether more lines are available, you must check
that it is larger than one. If so, you can safely assume that it
hold the number of available lines left.

As with all the functions operating on streams, you can safely
assume very little about this function, so consult the system and
implementation specific documentation.

     LINES()             –>   ‘1’  /* Maybe */
     LINES()             –>   ‘0’  /* Maybe */
     LINES(‘/tmp/file’)  –>   ‘2’  /* Maybe */
     LINES(‘/tmp/file’)  –>   ‘1’  /* Maybe */



PREV NEXT