Function DbeSetDefault() Foundation

Sets or returns the current database engine (DBE).

Syntax
DbeSetDefault( [<cNewDBEname>] ) --> cOldDBEname
Scope
thread-local, current workspace
Parameters
<cNewDBEname>
<cNewDBEname> is a character string containing the name of the database engine (DBE) to use as the default.
Return

The return value of DbeSetDefault() is a character string containing the last default DBE. If no argument was passed to the function DbeSetDefault(), the return value is the name of the current DBE. If no DBE is loaded, a null string ("") is returned.

Description

The function DbeSetDefault() sets the default database engine (DBE) used to open/manage data and index files. Also using this function, the name of the current DBE is returned when no argument is passed. The default DBE opens and manages files when no DBE name is specified with the command USE or the function DbUseArea().

Before DbeSetDefault() can be called, the DBE must be loaded. Otherwise a runtime error occurs. By default the DBE named DBFNTX is available. It is a compound DBE containing component DBEs from the files DBFDBE.DLL and NTXDBE.DLL.

Multithreading issues

The setting for the default database engine is valid for the current work space, or thread. If a new thread is started, it "inherits" this setting from the current thread, but may define its own default DBE for opening database files later on. In this case, the setting of the current thread remains unchanged.

Examples
Select a database engine

// The example demonstrates how a DBE is selected as the 
// current DBE with DbeSetDefault(). The return value of 
// DbeSetDefault() is saved in order to reset the 
// previous default DBE. 

PROCEDURE Main 
   LOCAL cOldDbe 

   ? DbeSetDefault()                 // result: DBFNTX 

   USE Customer                      // open CUSTOMER.DBF 
   COPY TO Temp.txt SDF              // copy to ASCII file 
                                     // (System Data Format) 

   ? cOldDbe := DbeSetDefault("SDFDBE") // result: DBFNTX 
                                     // SDFDBE is selected 
                                     // as current DBE 
   USE Temp                          // open ASCII file with USE 
   Browse() 
   CLOSE Temp 

   ? DbeSetDefault( cOldDbe )        // result: SDFDBE 
                                     // DBFNTX-DBE reset as 
RETURN                               // current default 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.