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 - index create an index file http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 index               Create an index file
------------------------------------------------------------------------------
 Syntax
   [!sAlias] index [cIndexName alias] sIndexAlias [unique]

 Arguments
   sAlias is the database to create an index for.

   cIndexName is the name of the index file.

   sIndexAlias is the index alias describing the key expression for the
   index.

 Description
   The index command creates an index file for the current or the specified
   database sAlias from a key expression specified in an indexdef
   declaration.

   If the command is called with just the sIndexAlias parameter, the name of
   the index file will be built from the expression sIndexAlias + ".FDX"
   unless another file name was assigned to sIndexAlias via the set alias to
   command before; in this case the assigned name will be used.

   If the command is called with the additional cIndexName parameter, the
   index file will be named to whatever is specified in cIndexName.

   If the unique clause is specified, records with identical key values will
   not be duplicated in the index file, i. e. the index file will only contain
   a reference to the first database record with this key value.

   When an index file is created, all filters, relations or any other open
   index files associated with the database are suspended or closed. The index
   order is set to 1. After index creation, a go top is automatically
   performed, to position the record pointer to the first logical record.

 Example
   #define EXAMPLE_DATABASE
   #include example.hdr

   indexdef
      char( 15 ) indexname upper( sTest->lastname )
   enddef
   
   proc Test_index
   // Index a file based upon the last name.
   open sTest
   index "name.fdx" alias indexname
   seek "Vanderbilt"
   ? found()
   seek upper( "Vanderbilt" )
   ? found()
   
   /*
   If the alias name has been initialized in a previous
   set alias <sIndexAlias> to <cFileName> command, then it is not
   necessary to specify the index file in the index command.
   */
   close index
   set alias indexname to "name.fdx"
   index indexname
   
   /*
   If two keys are identical, the unique flag indicates the key with the
   lowest record number is to be placed in the database.
   */
   set alias indexname to "nameuniq.dat"
   index indexname unique    // index file has only unique records
   
   // use the set index to command to order the index files
   index sIdxLN
   index sIdxB
   set index to sIdxLn, sIdxB
   close all
   erase "name.fdx"
   erase "nameuniq.dat"
   endproc

   proc main
   Test_index()
   endproc

See Also: open reindex set delete set filter to set relation to

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