Copy selected items to multiple tabs

Greeting Opus Friends

Objective
I am embarking on a grand scheme to construct a script that copies the currently selected items (in what is by definition the source tab) to multiple defined tabs.

Similar in some ways to this script
Copy into multiple selected destinations

Feasibility
Before I start it would be great to get any knowledgeable comments on the feasibility of this scheme. Can it be done? I initaly thought I would just hack the script above but I think it a bit more complicated then that.

Defining Multiple "Destination" tabs
This is the first problem that I have been chewing on.
The JScript default script enumerates ALL tabs on all listers.
The script above uses defined objects for the sourcetab and destinationtab.
So questions like this have been popping up in my mind

  • Can multiple destination tabs be defined? It would seem not
  • Is there any object that can represent or identify the (set of) tabs on either side of a dual lister?

Any comments much appreciated as always...

This post has made for interesting reading...
Error on Help File (tab.selected == collection of tabs)

You would run the Copy command once for each destination. The script you linked to does that.

Yes, the Lister object provides that.

1 Like

Thanks @Leo

In the mean time I had a stab at enumerating the tabs for the current lister.
Box in green is part of script mentioned above and you can see the working output for all tabs on all listers.
Box in red is my attempt to enumerate all tabs for the current lister.tabs collection only.
What am I doing wrong?

DOpus.listers returns a collection of all open listers (i.e. main windows), not just a single window.

If you want the window which the script was run from, you can get that from clickData.func.sourcetab.lister in most situations.

Alternatively, DOpus.listers.lastactive can be used if needed (e.g. a script that might be triggered outside of any lister) and is usually the same thing (unless the test is done a long time after the script was launched). But remember that it might return nothing if no lister windows are open at all.

1 Like

Thanks Leo
Well this turned out easier then I expected.
This little perl below now works.
It copies selected files/folders form the source tab to all (at least 2 tabs when I have tested anyway) RHS tabs. No error correction in place accepting to exit if the current lister is not in dual mode.
For example no handling construct if files/folders are selected in a RHS tab:

// Lists LHS and RHS tabs
function OnClick(clickData)
{
	// --------------------------------------------------------
	DOpus.ClearOutput();
	DOpus.Output("Current lister various:");
	// --------------------------------------------------------
	var cmd = clickData.func.command;
	cmd.deselect = false; // Prevent automatic deselection
	// --------------------------------------------------------
	// --------------------------------------------------------
	cLister = clickData.func.sourcetab.lister
	DOpus.Output("  Current Lister Dual value      :" + cLister.dual);
	DOpus.Output("  Current Lister Foreground      :" + cLister.foreground);
	DOpus.Output("  Current Lister Layout          :" + cLister.layout);
	DOpus.Output("");

	if (cLister.dual == 0)
	{
		clickData.func.dlg.Request("Need Dual Lister.","OK");
		DOpus.Output("  Dual value error exit          :" + cLister.dual);
		return;
	}


	
	DOpus.Output("Current Tabs LHS:");
	iii = 0
	for (var eTabs = new Enumerator(cLister.tabsleft); !eTabs.atEnd(); eTabs.moveNext())
	{
		DOpus.Output("     Tab " + iii + " in current lister   :" + eTabs.item().path);
		iii = iii + 1
	}
	DOpus.Output("Current Tabs RHS:");
	iii = 0
	for (var eTabs = new Enumerator(cLister.tabsright); !eTabs.atEnd(); eTabs.moveNext())
	{
		DOpus.Output("     Tab " + iii + " in current lister   :" + eTabs.item().path);
		cmd.AddLine("COPY TO=\"" + eTabs.item().path)
		iii = iii + 1
	}
	for (var eSel = new Enumerator(cmd); !eSel.atEnd(); eSel.moveNext())
	{
		DOpus.Output("    -->" + eSel.item());
	}
	cmd.Run();
	DOpus.Output("");

}

1 Like