Count total lines in a text file (file.line_count)
Declaration
count = file.line_count(path)
Parameters
- path
String. Absolute file path.
Returns
- count
Integer or nil. Total number of lines. 0 for empty file. nil if file does not exist.
Notes
Count total lines in a text file. Empty file returns 0.
Example
local linecount = file.line_count("/var/mobile/1.txt")
if linecount then
sys.alert("/var/mobile/1.txt has "..linecount.." lines")
else
sys.alert("/var/mobile/1.txt is not a file")
end
Note: Uses sys.alert