Function Select() Foundation

Returns the number of a work area based on the alias name.

Select( [<cAlias>] ) --> nWork area
<cAlias> is a character string containing the alias name of a work area.

The return value of Select() is a positive integer indicating the work area with the alias name <cAlias>. If no argument is passed, Select() returns the number of the current work area. When the alias name does not exist, zero is returned.


The database function Select() determines the number of a work area based on the alias name. It is often used with data driven applications where the work area in which a database file is open is unknown.

The command SELECT allows an expression in parentheses () to be specified. The command then becomes syntactically identical to the function call Select(). The command SELECT is normally translated by the preprocessor into the function call DbSelectArea() which selects a work area. The result is that the function call Select() will be translated to DBSelectArea() as long as Select() is not part of an expression.

// The example shows the difference between the function 
// Select() and the command SELECT with parentheses 

   USE Customer  ALIAS Cust  NEW 
   USE Invoice   ALIAS Inv  NEW 
   USE Item      ALIAS Item  NEW 

   ? Select()              // result: 3 
   ? Select("Stat")        // result: 2 
   ? Select("Cust")        // result: 1 

   Select( "Cust" )        // SELECT Command with parentheses 
   ? Select()              // result: 1 

   ? Select(0)             // result: 0  ( invalid alias ) 
   ? Select()              // result: 1 

   Select(0)               // SELECT Command with parentheses 
   ? Select()              // result: 4  ( next free work area ) 

   Select(2)               // SELECT Command with parentheses 
   ? Select()              // result: 2 



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.