Kludgy Commands Needed in Buttons; Script Doesn't Execute Command

Here is a button with commands that complete successfully:

//https://resource.dopus.com/t/evsearchlabels-search-for-opus-labels-using-everything-1-5/58704

@set SearchFor {dlgstringS|Search for a Label in T:.\n\nPlease enter the label name.|important}
EVSearchLabels IN T:\ PARTIAL QUERY ({$SearchFor})
Set FOCUS=Toggle
//Placeholder text to get the Label column added
/home\dopusrt.exe /cmd Set COLUMNSADD="Label"(2,*)

Question 1a: It works only if lines 6 and 7 are as you see them which is kludgy. Why must lines 6 and 7 be like that?

I thought to avoid the Question1a problem by using a script in the button:

//https://resource.dopus.com/t/evsearchlabels-search-for-opus-labels-using-everything-1-5/58704

function OnClick(clickData)
{
	var cmd = clickData.func.command;
	cmd.deselect = false;

	cmd.RunCommand('@set SearchFor {dlgstringS|Search for a Label in T:.\n\nPlease enter the label name.|important}');
	cmd.RunCommand('EVSearchLabels IN T:\ PARTIAL QUERY ({$SearchFor})');
	cmd.RunCommand('Set FOCUS=Toggle');
	cmd.RunCommand('Set COLUMNSADD="Label"(2,*)');
}

The EVSearchLabels command displays the correct labels and the script log shows no errors but the column is not added.

Question 1b: Why is the column not added? Is it somehow related to why lines 6 and 7 are required in Question 1a?

Any assistance appreciated.

Question 1a: Leo explained this here.

Question 1b: The cmd object hasn't been updated, its sourcetab is still the tab from before the dual-pane was opened. You can update it to the new tab with cmd.SetSourceTab(cmd.sourcetab.lister.activetab) before adding a column.

//https://resource.dopus.com/t/evsearchlabels-search-for-opus-labels-using-everything-1-5/58704

function OnClick(clickData)
{
	var cmd = clickData.func.command;
	cmd.deselect = false;

	cmd.RunCommand('@set SearchFor {dlgstringS|Search for a Label in T:.\n\nPlease enter the label name.|important}');
	cmd.RunCommand('EVSearchLabels IN T:\ PARTIAL QUERY ({$SearchFor})');
	cmd.RunCommand('Set FOCUS=Toggle');
	cmd.SetSourceTab(cmd.sourcetab.lister.activetab); 
	cmd.RunCommand('Set COLUMNSADD="Label"(2,*)');
}

You can avoid all of that if you create a folder format for a collection (say "coll://my labels") with the label column active and then reference that collname using the COLLNAME arg for EVSearchLabels

@a815 and @errante

Thank you very much.