ffindΒΆ

ffind finds the position of a string in a file.

rsPosition = ffind(fh, ssText)
rsPosition = ffind(fh, ssText, nBytes)

Return Value

rsPosition is the number of bytes between the current file position and the first character of the search string. If the string cannot be found, the function returns 0.

Parameters

fh

fh is a file handle created by calling the fopen function.

ssText

ssText is a scalar search string. Only the first 255 characters are used.

nBytes

nBytes sets the range from the current position in which the string is searched. If this parameter is not specified, the complete file is processed.

Comment

IMPORTANT: The file must be opened in binary (untranslated) mode.

Example

// Count lines
i = 0;
fh = fopen("c:/test.txt", "r");
while (ffind(fh,"\n") != 0) {
    i = i +    1;
}
fclose(fh);
print "No. of Lines:", i

id-1838938