Get list of WorkAreas or Aliases

Forum help and suggestions to improve this forum.

Moderator: Rathinagiri

Post Reply
trmpluym
Posts: 261
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands
Has thanked: 8 times
Been thanked: 27 times

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: 2423
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 734 times
Been thanked: 134 times
Contact:

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!)

User avatar
gfilatov
Posts: 714
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Has thanked: 27 times
Been thanked: 313 times
Contact:

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: 261
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands
Has thanked: 8 times
Been thanked: 27 times

Post by trmpluym »

Serge, Grigory,

Thanks !

Theo

Post Reply