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>with the contains ( $ ) operator</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  With the Contains ( $ ) Operator

  Mach SIx uses the Contains ($) Operator in a totally different manner than
  straight Clipper.  Keep in mind that in order for Mach SIx to optimize an
  expression, the value in the expression must be one that you could perform
  a SEEK on.  Since you cannot SEEK for a value contained in the middle of a
  key, Mach SIx cannot optimize a query based on a value that is truly con-
  tained within a field.  Instead, Mach SIx allows you to use the contains
  operator to simplify a search for different values within the same field.

  For example, to set a filter for all records where the STATE field is
  equal to "CA", "AZ", or "NY" you could either do this:

    SET FILTER TO STATE=="CA" .OR. STATE=="AZ" .OR. STATE=="NY"

  Or you could do this:

    SET FILTER TO STATE $ "CA AZ NY"

  As you can see, the second method is much simpler.  In this example, the
  spaces separate the values just to keep Mach SIx from mistakenly looking
  for other values we don't want.

  Say, for example, that we wanted to look at all records where STATE was
  equal to "NC", "AL", or "AZ".  If we did this:

    SET FILTER TO STATE $ "NCALAZ"

  ...Mach SIx would set the filter for all records where the STATE field was
  equal to "NC", "CA", "AL", "LA", and "AZ".

  Mach SIx takes the length of the field and moves one byte at a time
  through the search string, reading in the same number of bytes as the
  search field is wide.  In this example, the STATE field is two bytes
  wide.

  With this in mind, you MUST insure that any search strings are padded
  with spaces to the length of the field being searched.  For example, if
  you wanted to look at all records where the LAST field (10 bytes wide)
  contained either the name Smith, Jones, or Thompson, you'd need to do
  this:

                                   1         2         3
                          123456789012345678901234567890
    SET FILTER TO LAST $ "Smith    Jones     Thompson  "

  To summarize, using the contains operator you can optimize queries on a
  single field with a list of items.  In order to be optimized the query
  must take on the form of the examples below.

       // Assumes the STATE field is two characters long
       COUNT TO nCount FOR STATE $ "CA,NC,FL,SC,IL,GA"

       // Assumes the PAYDATE field is four characters long
       COPY TO Temp FOR PAYTYPE $ "CASH CHCK CRED"

       // Assumes the LAST field is ten characters long
       SET FILTER TO LAST $ "Smith     Jones     Thompson  "

  The field must be listed to the left of the "$" and the list ( or
  string ) must be greater than or equal to the width of the field.
  Queries like the following are not optimizable:

         SUM Amount TO nAmount FOR "S" $ Last

  Note that the items in the "list" need not be delimited with a common
  character.  The "," and " " were placed in the string to prevent
  erroneous matches.  The following is an example of a query using a
  single character indexed field DEBTCODE that is optimizable without
  specifying any delimiters.

        COUNT TO nCount FOR  DebtCode $ "ABCDEFG"

  If there is ever a question whether a query condition is optimizable,
  check its optimization level with the m6_IsOptimize() function.


See Also: m6_IsOptimize()

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