MIAMEX 147: Count Lines in File

xcall MIAMEX, MX_FLINES, channel, lines {,linelen, slinelen}

MX_FLINES allows you to quickly count the number of lines in a sequential file, and also determine the length of the longest line either with or without trailing spaces.

Parameters

channel  (Num)  [in]

must be set to the file channel number of a file open for sequential input.

lines  (Signed Num)  [out]

returns the number of lines in the file. A negative number indicates an error (-1 means the file channel was invalid, -x indicates that system error x occurred while reading the file.)

linelen  (Num)  [out]  optional

returns the length of the longest line in the file (including trailing spaces plus one for the trailing terminator).

slinelen  (Num)  [out]  optional

returns the length of the longest line in the file excluding any trailing unprintable characters (such as spaces, tabs, CR, LF, etc.)

The file is left open, with the file cursor set to the beginning of the file.