Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- FAST TEXT SEARCH for Clipper v.2.0 - <b>searching multiple fields across related dbfs</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
   Searching Multiple Fields Across Related DBFs

   Using CFTS to search across related .DBFs might, at first, seem 
   daunting, but the task is really quite straight forward. The technique 
   is not really different from what is required when indexing and 
   searching multiple fields. First, open all the .DBFs, their .NTX 
   indexes, and set the relations between them. Next, generate the CFTS 
   index by stepping through the master .DBF, passing to CFTS the string 
   comprising the data from all the fields and all .DBFs that you want to 
   be searchable. Remember to create the CFTS index in the natural order 
   of the primary .DBF.

   xhandle = CftsCrea( office.ia, 20, 3, .T., 1 )
   select 0
   use name index name
   select 0
   use office
   set relation to office->name into name
   do while ! eof()
   instring = trim( office->name ) + trim( name->street );
            + trim( name->city ) + trim( name->state )
   rec = CftsAdd( xhandle, instring )
   skip
   enddo
   
   Later in you program, you might SELECT into NAME, like this:

   select name

   Now, assuming you wanted to search NAME.DBF using CFTS, simply do the 
   following:

   srchstring = Mayflower Street
   CftsSet( xhandle, srchstring )
   xrec = CftsNext( xhandle )
   do while xrec > 0
   select office          && switch back to master.DBF
                          && for goto The SET RELATION 
   goto xrec              && established above will move us 
                          && to the correct record in NAME.
   <verify data>          && See CftsVeri()
   xrec = CftsNext( xhandle )
       select name
   enddo


See Also: CftsVeri()

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