Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - find search an index for a matching record http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 find                Search an index for a matching record
------------------------------------------------------------------------------
 Syntax
   [!sAlias] find cSearch

 Arguments
   sAlias is the database to operate on.
   cSearch is a character expression that specifies the search string.

 Description
   The find command attempts to find the first record in an indexed database
   where the index key matches cSearch. The find command is similar to the seek
   command, except that find can only locate character data.

   If find can not locate a matching record, eof() returns .t., and
   found() returns .f.. find respects the status of the set exact flag
   when comparing cSearch against the index keys.

   If the system variable __soft_seek is .t., the record pointer will be
   moved to the next record with a higher key after a failed index search. In
   this case, eof() will not return .t., but found() will still return .f.

 Example
   #define EXAMPLE_DATABASE
   #include example.hdr

   proc Test_find
   vardef
      char cSearch
   enddef
   cSearch := "Canady"
   open sTest index sIdxLN
   find cSearch                 // find a name in the index file
   if found()
      ? "Last name", cSearch, "found in record", istr( recno() )
   endif
   // allow user to specify the search string
   accept "Input search name: " to cSearch
   find cSearch
   if found()
       ? cSearch, "found"
   else
       ? cSearch, "not found"
   endif
   endproc

   proc main
   Test_find()
   endproc

See Also: aeof() eof() found() locate seek set exact

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