Change Button Label Based on Active Tab Path

What, if any, evaluator method can be used to change a button label based on the active tab path?

Try =lister_title=="D:\Downloads" ? "yes" : "No"

image

Depends on your goal, so basically all :slight_smile:

Here's a simple example:

@label:"Drive is " + Left(source, 2)

Thanks for these examples. Goal is to show active tab in label regardless of location and not limited by folder depth. For example, one could have two tabs open:

"D:\Downloads"
"C:\Users\UserName\Documents\Reports"

Label would reflect whichever tab were active and change labels with active tab change.

Do you want the complete path? Then all you need is

@label:source

Thanks @lxp!

Next level, I use a custom titlebar that parses the active path to shorten long paths:

function OnOpenLister(OpenListerData)
{
	tab = OpenListerData.lister.activetab;
	cmd.SetSourceTab(tab);

//Remove trailing .0 on DOpus version
	var s = (''+DOpus.Version.product).slice(0,-2);

	//Build Lister Title
	title = "notoggle:Directory Opus " + s; // + " [" + build + "]";
	
	var id = tab.path.def_value;
	if (tab.path.test_root == 0) //Check if at root drive  
	{
		if (id.substr(id.length - 1) == "\\")
		{
			title = title + "    |    %R\\"; //Ensures root drive displayed properly
		} else
		{
			title = title + "    |    %R";
		}
	} else
	{
		title = title + "    |    %R\\...\\%N";
	}
	
	DOpus.Output(title);
	DOpus.output(version);

	cmd.RunCommand('Set LISTERTITLE="' + title + '"');
}

I'm thinking this could be accomplished via evaluator and Regex. Do I have that right? If not, what options exist?

You want to implement the title bar logic in the label button? Something like this?

@label:Count(source)>2 ? Root(source) + "\..\" + FilePart(source) : source
2 Likes

Perfect! Thanks lxp!