Page 1 of 1

Get list of WorkAreas or Aliases

Posted: Sun Feb 02, 2020 9:07 pm
by trmpluym
Hi friends,

How can i get a list of all databases currently openend.

Alias() returns the alias of the current work area.

But is there a function to get an array of all opened databases or another way to retrieve this list ?

Theo

Re: Get list of WorkAreas or Aliases

Posted: Mon Feb 03, 2020 8:21 am
by serge_girard
Hi Theo !

Try this:

Code: Select all

FOR x := 1 TO 55
	SELECT( x )
	IF !EMPTY( ALIAS(x) )
	
		? SELECT()  
		? ALIAS() 
		? RECNO() 
		? DBFILTER()  
		? DBRELATION()  
		? INDEXORD()  
		? INDEXKEY( INDEXORD() )  
	ENDIF
NEXT
 
Serge (see you soon!)

Re: Get list of WorkAreas or Aliases

Posted: Mon Feb 03, 2020 8:37 am
by gfilatov
trmpluym wrote: Sun Feb 02, 2020 9:07 pm But is there a function to get an array of all opened databases or another way to retrieve this list ?
Hi Theo,

Yes, it is exist.

Please take a look for the following code snippet:

Code: Select all

   LOCAL aAlias := {}
   LOCAL cur_id
   LOCAL nOldArea := Select()

   hb_WAEval( {|| AAdd( aAlias, { Select(), Alias() } ) } )

   IF Len( aAlias ) == 0
      Alert( "No workareas in use" )
      RETURN
   ENDIF

   IF ( cur_id := AScan( aAlias, {| x | x[ 1 ] == nOldArea } ) ) == 0
      cur_id := 1
      dbSelectArea( aAlias[ 1 ][ 1 ] )
   ENDIF
...
   dbSelectArea( nOldArea )
:idea:

Re: Get list of WorkAreas or Aliases

Posted: Mon Feb 03, 2020 8:39 am
by trmpluym
Serge, Grigory,

Thanks !

Theo