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 - set alias to establish a file name for an alias http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 set alias to        Establish a file name for an alias
------------------------------------------------------------------------------
 Syntax
   set alias sAlias to cFile

 Arguments
   sAlias is the alias to associate with a file name.
   cFile is the name of a database file.

 Description
   The set alias to command establishes a file name for an alias.
   It defines the correspondence between an index or database alias
   and a file name.

   When a dbfdef or indexdef is compiled, the default filenames
   corresponding to the aliases are derived from the alias name. For
   example, if a dbfdef is defined as:

   dbfdef abc
      // field declarations
   enddef

   then the default filename for the alias will be abc.dbf. Likewise for an
   indexdef, except an index file has a .fdx extension.

   To use a different filename than the one derived by default from the
   alias name, use the set alias to command.

   To get the current filename associated with an alias, use the dbf() or
   fdx() functions.

 Example
   #define EXAMPLE_DATABASE
   #include example.hdr

   dbfdef sNames2               // no fields will be referenced
   enddef
   
   proc Test_setaliasto
   // use the same database alias for two different files
   // (only one may be open at one time)
   open sTest                   // open source database
   copy to "snames2.dbf"        // copy database
   go top
   sTest->firstname := "FIRST"  // change 1st record
   ? sTest->firstname
   close sTest
   ? adbfname( sTest )          // print name of file associated with alias
   // the set alias command allows for long filenames
   set alias sTest to curdir( 0 ) + "\snames2.dbf"
   ? adbfname( sTest )          // print name of file associated with alias
   open sTest                   // open second database
   ? sTest->firstname
   ? afdxname( sIdxLN )         // name of file associated with index alias
   set alias sIdxLN to "ln.idx" // change file associated with index alias
   ? afdxname( sIdxLN )         // name of file associated with index alias
   index sIdxLn
   close all                    // clean up
   erase "snames2.dbf"
   erase "snames2.dbt"
   erase "ln.idx"
   endproc

   proc main
   Test_setaliasto()
   endproc

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