Function WorkSpaceEval() Foundation
Evaluates a code block in all used work areas of a work space
WorkSpaceEval( <bAreaBlock>, [<nWorkSpace>] ) --> nProcessed
Constant | Description |
---|---|
DB_ZEROSPACE | WorkSpaceEval() is executed in the Zero space |
DB_WORKSPACE *) | WorkSpaceEval() is executed in the current work space |
|
The function returns a numeric value that indicates the number of work areas where the code block <bAreaBlock> is evaluated.
The function WorkSpaceEval() evaluates a code block in all used work areas of a work space. It is used, for example, to set, save or restore the environment within all work areas. If DB_ZEROSPACE is specified, information about work areas pending in the Zero space can be retrieved, which normally is not possible without a prior call to DbRelease().
// In the example, the function UsedAreas() is programmed. It
// returns an array containing the numbers of all used work areas.
FUNCTION UsedAreas()
LOCAL aUsed := {}
WorkSpaceEval( {|| AAdd( aUsed, Select() ) } )
RETURN aUsed
// The example demonstrates how to save and restore the current
// state of all work areas. The user-defined function SaveWorkSpace()
// saves and RestWorkSpace() restores the state of the work areas.
**********************
FUNCTION SaveWorkSpace
LOCAL aSaved := {}
WorkSpaceEval( {|| AAdd( aSaved, SaveWorkarea() ) } )
RETURN { aSaved, Select() }
*********************
FUNCTION SaveWorkarea
RETURN { ;
{ Select() , {|x| DbSelectArea(x)} }, ;
{ OrdNumber(), {|x| OrdSetFocus(x) } }, ;
{ Recno() , {|x| Dbgoto(x) } } }
********************************
FUNCTION RestWorkSpace( aSaved )
AEval( aSaved[1] , ;
{|a| AEval( a, {|aa| Eval( aa[2], aa[1] ) } ) } )
RETURN DbSelectArea( aSaved[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.