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 - open open database, memo and index files http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 open                Open database, memo and index files
------------------------------------------------------------------------------
 Syntax
   open [cFile alias] sAlias [index indexes] [shared|exclusive|readonly]

 Arguments
   cFile is the name of the database file to open.
   sAlias is an alias declared in a dbfdef block.
   indexes is a list of index aliases.

 Description
   The open command opens a database with index files and associated memo
   files, assigning the database file to alias sAlias.

   open is the preferred command for opening a database file and its
   associated indexes. Unlike the use command, several databases can be
   opened at one time without concern for the status of select or the
   current work area.

   open does not imply the close of a database. Unlike the use command, open
   will not close the currently selected database To close an opened file,
   use the close command.

   A work area sAlias is created when open is issued. open changes the
   current work area to sAlias. Use select to change the active work area.

   The cFile argument defines the file to be used. If cFile is not defined,
   then the open command will try to open the file set by the last set alias command
   or cFile.dbf if no alias is set.

   If the indexes argument is specified, the first index file in the list
   will become the master index file. If no extension is specified, then .fdx
   is assumed.

   If opening a database in shared mode, do not open any associated indexes
   through the index clause. This assures proper interpretation of the
   neterror() error code.

   The open command returns if it can not open a shared database due to a
   network error. It does NOT return if the error condition is caused by a
   non-network error. Use the neterror() function to obtain the network error
   code.

   The default state for set exclusive is on, meaning that the programmer
   must explicitly set it off in order to enable file sharing.

   If set exclusive is off, the clauses shared and exclusive may be used to
   specify the access rights to individual database files. shared allows the
   database file to be used by several users on a network. exclusive
   specifies that the database file should be used by one person.

   The clause readonly opens the database file in read-only mode. It is the
   programmer's responsibility to avoid any write operations while the file
   is opened in this mode - otherwise a run-time error will occur.

 Example
   #define EXAMPLE_DATABASE
   #include example.hdr

   proc Test_open
   open sTest                    // open database with default file name
   ? adbf( sTest )               // show file name for alias
   copy to "copy.dbf"            // make a copy of the database
   close sTest                   // close stest.dbf
   open "copy.dbf" alias sTest   // open copied database with same alias
   ? adbf( sTest )               // show file name for alias
   close sTest                   // close copy.dbf
   set alias sTest to "copy.dbf" // associate file name with alias
   ? adbfname( sTest )           // show name association before opening
   open sTest index sIdxLn       // open database with index
   ? adbf( sTest )               // show file name for alias
   !sTest append blank           // add a record
   ? areccount( sTest )          // show record count
   select sTest                  // select alias (for demo only)
   append blank                  // add a record
   ? areccount( sTest )          // show record count
   close all                     // clean up
   erase "copy.dbf"
   erase "copy.dbt"
   endproc

   proc main
   Test_open()
   endproc

See Also: close use

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