.. highlightlang:: us .. index:: ffind .. _ffind: ffind ===== .. us.tag ffind ENGLISH ffiles :ref:`ffind` finds the position of a string in a file. .. function:: rsPosition = ffind(fh, ssText) rsPosition = ffind(fh, ssText, nBytes) .. us.return **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. .. us.params **Parameters** .. uparam:: fh *fh* is a file handle created by calling the :ref:`fopen` function. .. uparam:: ssText *ssText* is a scalar search string. Only the first 255 characters are used. .. uparam:: 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. .. us.comment **Comment** **IMPORTANT**: The file must be opened in binary (untranslated) mode. .. us.example **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 .. seealso:: :ref:`overview-binary-and-text-files`, :ref:`fopen`, :ref:`fseek` :sub:`id-1838938`