Last week I wrote a new version of my custom function FrontTabs. The function retrieves the object names of all open tabs. Another developer discovered an error in the previous version. With three or more nested tab controls the function could return a wrong result. It was time to rewrite the function. The new version takes care of that problem.

The function FrontTabs returns a list with all currently open tabs, so called front tabs. Of course, all tabs must have an object name. The returned object names are listed in the order of the nested tab controls, starting with the utmost tab control. This makes it easy to recreate a previous saved front tabs status.

I use global variables in the format $$LAYOUT.NAME_FRONTTABS to store the current front tabs status. In an OnLayoutLoad trigger script, I use this variable in a loop. There I apply the command Go to Object with every name in the list to recreate the saved front tabs status.

But enough about how to use this function. I know, you will have your own creative ideas.

Custom Function FrontTabs

This function does not expect any function parameters. The return value is a text list.
Without any tab control in the current layout, the function will return an empty text (“”).

Function FrontTabs
Let( [
	$frontTabs_objectList = If( IsEmpty( $frontTabs_objectList );
			Substitute( LayoutObjectNames( Get( FileName ); Get( LayoutName ) ) & ¶; ["< ¶"; ""]; [">¶"; ""] );
		// Else
			$frontTabs_objectList
		);
	_object = GetValue( $frontTabs_objectList; 1 );
	_enclosingObject = GetLayoutObjectAttribute( _object; "enclosingObject" );
	$frontTabs_objectList = MiddleValues( $frontTabs_objectList; 2; 1000000 )
];
	Case(
		not GetLayoutObjectAttribute( _object; "isFrontTabPanel" );
			"";

		_enclosingObject = "";
			Let( $frontTabs_frontTabs = $frontTabs_frontTabs & _object & ¶; _object & ¶ );

		Position( ¶ & $frontTabs_frontTabs; ¶ & _enclosingObject & ¶; 1; 1 ) > 0;
			Let( $frontTabs_frontTabs = $frontTabs_frontTabs & _object & ¶; _object & ¶ );

	) & If( not IsEmpty( $frontTabs_objectList );
		FrontTabs;
	// Else
		Let( $frontTabs_frontTabs = ""; "" )
	)
)

2 Responses

You have a couple of typos:
- In the Substitute() on the third line, you have a space in the sting “< ¶"
- In the Case, the first Let() says "Let( $FONTTabs_frontTabs = …" instead of "Let( $FRONTTabs_frontTabs = …"

Thanks for pointing it out! I made the corrections.

You must be logged in to post a comment.