Function DbSelectArea() Foundation

Selects a work area.

Syntax
DbSelectArea( <nWorkArea> | <cAlias> ) --> NIL
Parameters
area <nWorkArea>
<nWorkArea> is a positive integer specifying the ordinal number of the work area being selected.
<cAlias>
Alternatively <cAlias> can be specified for <nWorkArea>. If used, <cAlias> is a character string containing the alias of the work area being selected.
Return

The return value of DbSelectArea() is always NIL.

Description

The function DbSelectArea() selects a work area and sets it as the current (active) work area. All functions called without the alias operator perform their operations in the current work area. The function receives either the numeric value (ordinal number) of a work area or its alias name. When the value 0 is passed to DbSelectArea(), the function selects the work area with the lowest ordinal number and no open files (the next free work area).

The command SELECT can be used instead of the function DbSelectArea().

Examples
DbSelectArea()
// The example illustrates the effect of the function 
// DbSelectArea() and of the alias operator 

PROCEDURE Main 
   USE Customer NEW 
   USE Invoice NEW 

   ? RecNo()                // result: 1 
   ? Select()               // result: 2 
   DbSkip() 
   ? RecNo()                // result: 2 

   ? Customer->(RecNo())    // result: 1 
   ? Customer->(Select())   // result: 1 
   ? Invoice->(Select())    // result: 2 

   DbSelectArea("Customer") 
   ? RecNo()                // result: 1 
   ? Select()               // result: 1 

   ? (2)->(Alias())         // result: INVOICE 
   ? (2)->(RecNo())         // result: 2 

   DbSelectArea(0) 
   ? Alias()                // result:      (null string("")) 
   ? Select()               // result: 3 

   CLOSE DATABASES 
RETURN 

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.