Get list of WorkAreas or Aliases

Forum help and suggestions to improve this forum.

Moderator: Rathinagiri

Post Reply
trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Get list of WorkAreas or Aliases

Post 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
User avatar
serge_girard
Posts: 3162
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Get list of WorkAreas or Aliases

Post 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!)
There's nothing you can do that can't be done...
User avatar
gfilatov
Posts: 1060
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Get list of WorkAreas or Aliases

Post 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:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: Get list of WorkAreas or Aliases

Post by trmpluym »

Serge, Grigory,

Thanks !

Theo
Post Reply