Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- FUNCky - <b>name:</b> <b>fstrcount() - how many times a string appears in a file</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  Name:     fstrcount() - how many times a string appears in a file
  Usage:    <integer> = fstrcount(<handle>,<string>,[<case>])
  Params:   integer <handle> from a previous fopen() or fcreate()
            string <string> - the string to locate in the file
            logical <case> - optional case specifier. If <case>
            is .T., then the text of the file is converted to uppercase
            before it is compared to <string>. If <case> is false,
            then the text is converted to lowercase before it is
            compared to <string>. If this parameter is left off,
            then the  text is left as is. To search for non case
            sensitive text, use the appropriate <case> value, and
            then convert the string to be searched for to either upper
            or lower case. Note that converting the text in the file
            to either upper or lower case does not modify the text in
            that file.

  Returns:  an integer equal to the number of times that <string> is
            found in the file identified by <handle>

 ---------------------------------- Example ---------------------------------

                 handle = fopen("data.txt")
                 numdata = fstrcount(handle,"DATA",.T.)
                 if numdata = 0
                      return(0)
                 endif
                 public datarray[numdata]
                 for xx = 1 to numdata
                      if (flocate(handle,"DATA",.T.) > -1)
                           datarray[xx] = freadline(handle)
                      else
                           return(xx-1)
                      endif
                 next

  Note:     Clipper source code is provided as an example on how
            to use flocate(). See the file c_fstrco.prg. this function
            is affected by the abort option in flocate().


See Also: freadline() flocate() flinecount() ferror()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson