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>what are roll-your-own indexes? how do i make them?:</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  What are "Roll-Your-Own" indexes?  How do I make them?:

  "Roll-Your-Own" (RYO) indexes are indexes created using some of the
  extended functions of the SIx Driver:  INDEX ON ... EMPTY, Sx_KeyAdd() and
  Sx_KeyDrop().  These let you build a customized index one key at a time,
  or modify an existing index by adding or removing keys.  Absolute control!

  To make a new RYO index, first create an empty index with the desired
  attributes (key, filter condition, descending, etc.).  This is done using
  the INDEX command with the EMPTY keyword.  For example, to create an
  empty CUSTOM.IDX (or CUSTOM.NSX under SIXNSX), with LNAME as the index
  expression:

     INDEX ON LNAME TO CUSTOM EMPTY

  Now, you should either make another index active or SET ORDER TO 0.  This
  is because the new index has no keys, so no records are visible.  You
  might do something like this:

     INDEX ON LNAME TO CUSTOM EMPTY  // Create the custom index
     SET INDEX TO NORMAL, EMPTY      // Open an existing index and new one

  This makes NORMAL.IDX the active index, with EMPTY.IDX open in ORDER 2.

  Here comes the fun part - adding keys to the index!  For each record that
  you want to add to your new index, simply call Sx_KeyAdd().  For example:

   ...move to desired record, then...

     Sx_KeyAdd(2)              // The index is open in ORDER 2

  Removing keys is just as easy:

   ...move to desired record, then...

     Sx_KeyDrop(2)             // The index is open in ORDER 2

  RYO indexes are different from ordinary indexes.  They are updated when
  an existing key changes, but appending or deleting records is not
  automatically reflected in an RYO index.

  Another difference is the way the REINDEX command is handled.  RYO IDX's
  are simply ignored during a REINDEX.  This allows them to retain their
  custom set of keys.

  RYO tags in a compound index (.CDX/.NSX) are handled a bit differently.
  Due to the structure of .CDX and .NSX indexes, they are rebuilt from
  scratch during a REINDEX.  RYO tags are reset to 0 keys during a
  REINDEX, so the keys must be added again using Sx_KeyAdd().  Therefore,
  if you want to retain the contents of RYO indexes and you use the REINDEX
  command then keep your RYO's as IDX's or seperate (single-tag) .NSX's.


    NOTE: Multi-Keyed RYO indexes are NOT created with the EMPTY keyword,
          but with the sxChar(), sxNum(), sxLog(), or sxDate() functions.

          See the RYODEMO.PRG program for an example of using standard RYO
          indexes (Created with the EMPTY clause).

          See the HYPER.PRG and MULTIKEY.PRG programs for examples of using
          Multi-Keyed, Free-Format RYO indexes.



See Also: Multi-Key, Free-Format Indexes Sx_KeyAdd() Sx_KeyDrop() sxChar()

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