Active Tab List without custom function

In case this is useful to anyone, or in case anyone spots an error, I had the need today to create a list of active tab panels in a layout to revert to after running a script that could change these.

There is an ‘tabsActive’ custom function on Brian Dunning’s website FileMaker Custom Function: tabsActive ( layoutObjects ) but we are continuing to move away from custom functions now that we have the While() function.

This appears to work upon first testing:


While ( [
//initialVariables
	~file = Get ( FileName ) ;
	~layout = Get ( LayoutName ) ;
	~objects = LayoutObjectNames ( ~file ; ~layout ) ;
	~objectCount = ValueCount ( ~objects ) ;
	~tab = "" ;
	~res = ""
] ;
//condition
	~objectCount > 0
;
//logic
[
	~tab = If ( GetLayoutObjectAttribute ( GetValue ( ~objects ; 1 ) ; "isFrontTabPanel" ) = 1 ; GetValue ( ~objects ; 1 ) ; "" ) ;
	~objectCount = ~objectCount - 1 ;
	~objects = RightValues ( ~objects ; ~objectCount ) ;
	~res = 
		Case (
			IsEmpty ( ~tab ) ; ~res ; 
			IsEmpty ( ~res ) ; ~tab ;
			~res & ¶ & ~tab 
		)
] ;
//result
	~res
)

Kind regards
Andy

3 Likes

I forgot to mention, each tab must have an object name applied for the above to work

2 Likes

Is it possible to reconstruct this in the wrong sequence? In other words, have all the correct tabs showing topmost but because of stacking order, have a different view?

Hi Malcolm

Yes, absolutely. There is no layering data involved, so tabs within tabs could result in a different view. This works the same way as the custom function and was was fine for my needs.

To be honest, in most cases opening a new window, carry out a find, set the data and close the card is the safest way to preserve the view.

Kind regards
Andy

A later thought on this. If some sort of layered info was added to the tab panel object names, then it would be possible to control the order in which the data was used to ensure the view remained correct.