Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- SIx Driver RDD v3.00 - Reference Guide - <b>searching multiple fields:</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  Searching Multiple Fields:

  Using HiPer-SEEK to search multiple fields solves the problem of finding
  items in a .DBF when you do not know with certainty in which field the
  data is to be found. For example, imagine a file in which four fields
  have been reserved for medical diagnoses. Each field contains a
  diagnosis. To find all records containing the diagnosis heart disease
  without using HiPer-SEEK you would probably resort to a slow sequential
  search using the LOCATE command.

    LOCATE FOR "HEART DISEASE" $ Upper( diag1 ) .OR. ;
               "HEART DISEASE" $ Upper( diag2 ) .OR. ;
               "HEART DISEASE" $ Upper( diag3 ) .OR. ;
               "HEART DISEASE" $ Upper( diag4 )       

  In contrast, HiPer-SEEK provides a quick solution. Assuming you create an
  index consisting of all the fields you intend to search by concatenating
  the fields;

    Trim( diag1 ) + Trim( diag2 ) + Trim( diag3 ) + Trim( diag4)

  and then passing the resulting string to hs_Add(); a search for all
  instances of heart disease becomes:

    USE diagnose
    h := hs_Open("diag.hsx", 16, 1 )
    cStr := "HEART DISEASE"
    hs_Set( h, cStr )
    nRec := hs_Next( h )     // get first hit
    DO WHILE nRec > 0        // get all the records
      GOTO nRec              // get record in .DBF
      bVeri := { || Trim(diag1) + Trim(diag2) + Trim(diag3) + Trim(diag4) }
      IF hs_Verify( bVeri, cStr ) == .T.
      .
      . < process verified hit >
      .
      ENDIF
      nRec := hs_Next( h )   // get next 'hit'
    ENDDO

  Although the code is somewhat more complicated than using LOCATE,
  HiPer-SEEK's speed and generality lets you create applications that are
  easier to use and which certainly execute much more quickly.


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