Get the number of strings of a specified text file. The end of the line is a set of symbols CRLF (ASCII #13#10).
function GetTextFileLinesCount(sFileNameWithPath: string; iEncodingType: integer): int64;
Parameter |
Type |
Value |
---|---|---|
sFileNameWithPath |
string |
a name of a text file with a full path to it; |
iEncodingType |
integer |
file encoding type, number. |
-1 file does not exist;
-2 file access error;
>=0 a number of lines in a text file.
const
FILE_NAME = 'F:\Doc\MyChatJSONprotocol.txt';
var
iCount: int64;
begin
iCount := GetTextFileLinesCount(FILE_NAME, 0);
if iCount = -1 then mLogScript('File not found!', '')
else mLogScript(IntToStr(iCount) + ' lines total', '');
end.
[16:32:20] (Log "GetTextFileLinesCount"): 7015 lines total
[16:32:20] (Run "GetTextFileLinesCount"): Script operation time: 30 ms
[16:32:20] (Run "GetTextFileLinesCount"): Script done successfully.