Hello Przemek

Przemyslaw Czerpak-2 wrote:
> 
> I just wanted to suggest you something like that.
> I'll add HB_WALIST()/HB_WAEVAL() functions which should help in
> writing function to iterate workareas.
> 

If you are into that:

Xbase++ functions to this effect:


Syntax 

WorkSpaceEval( <bAreaBlock>, [<nWorkSpace>] ) --> nProcessed 

Parameters 

<bAreaBlock>

The argument <bAreaBlock> must be a code block. It is evaluated in all used
work areas of the work space specified with <nWorkSpace> . 

<nWorkSpace>

Constants from DMLB.CH must be used for the optional argument <nWorkSpace> .
It specifies the work space in which WorkSpaceEval() is executed. The
following table lists all valid constants: 

Constants to specify the work space 

  Constant         Description                                              

  DB_ZEROSPACE     WorkSpaceEval() is executed in the Zero space            
  DB_WORKSPACE *)  WorkSpaceEval() is executed in the current work space    

 *) default

Return 

The function returns a numeric value that indicates the number of work areas
where the code block <bAreaBlock> is evaluated. 

Description 

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(). 

Example - 1 

// Determine which work areas are used 

// 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 

Example - 2 

// Save the current state of all work areas 

// 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] ) 

*************************************************************

Syntax 

WorkSpaceList( [<nWorkSpace>] ) --> aAliasNames 

Parameters 

<nWorkSpace>

Constants from DMLB.CH must be used for the optional argument <nWorkSpace> .
It specifies the work space in which WorkSpaceList() is executed. The
following table lists all valid constants: 

Constants to specify the work space 

  Constant         Description                                              

  DB_ZEROSPACE     WorkSpaceList() is executed in the Zero space            
  DB_WORKSPACE *)  WorkSpaceList() is executed in the current work space    

 *) default

Return 

The function returns a one-dimensional array. It contains character strings
with the alias names of all used work areas. If no work area is used, an
empty array is returned. 

Description 

With the function WorkSpaceList(), the number of work areas used at a given
time can be determined as well as a list of all alias names in use. The
function is a specialized form of WorkSpaceEval(). 

*********************************************

It will be nice if you used above namespace.
We will be more near to Xbase++.

Regards
Pritpal Bedi

-- 
View this message in context: 
http://www.nabble.com/MT-workareas-cloning-tp24050058p24055313.html
Sent from the Harbour - Dev mailing list archive at Nabble.com.

_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to