I am certain there is an answer to this - but can't find it.
I need to search in all tabs in all listers so I can quickly go to currently open tab.
Is there a way to do it, or is there a script to use?
Thank you all!
Could you provide a little more information on what you're trying to achieve, it's not clear from your question.
You seem to want to search tabs from their title but then say you want the "currently open tab".
Both are achievable through scripting.
DOpus.GetListers
will get you all the listers (a Listers
object). You can iterate that or get the last active lister from it (Listers.lastactive
).
Lister.tabs
will get you all the tabs from a lister (which can be enumerated), and Lister.activetab
will get you the active tab for that lister.
Tab.path
gives you the path of the tab and Tab.label
gives you the current label of the tab.
From scripting, you can use a tab variable (e.g. myTabVariable
) in some commands, like so :
cmd.RunCommand("Go TABSELECT=$" + myTabVariable);
All this can be found from the manual
Hello, thanks for the answer. I want to search in listers and in all tabs.
I have this properly running:
function OnClick(clickData)
{
var dlg = clickData.func.Dlg;
dlg.title = "Dialog Test";
dlg.message = "Enter text for the test:";
dlg.buttons = "OK|Cancel";
dlg.icon = "question";
dlg.max = 256;
dlg.input = "";
// Showing the dialog
var result = dlg.Show();
if (result != 1) {
DOpus.Output("Search was canceled.");
return;
}
// Storing the entered text in a variable
var searchQuery = dlg.input;
// Iterating through all Listers
var listers = DOpus.listers;
for (var eListers = new Enumerator(listers); !eListers.atEnd(); eListers.moveNext()) {
var lister = eListers.item();
DOpus.Output("Found Lister with title: " + lister.title);
// Iterating through the tabs in the current Lister
for (var eTabs = new Enumerator(lister.tabs); !eTabs.atEnd(); eTabs.moveNext()) {
var tab = eTabs.item();
DOpus.Output(" Found tab with path: " + tab.path);
}
}
// Outputting the entered text
DOpus.Output("Text you entered: " + searchQuery);
}
However the moment I try to search - can't, error Object doesn't support this property or method (0x800a01b6)
I thought it is implemented in DO the tabs search, but perhaps it is not and I am the only one needing it. So will try on working, this is the current state where there error appear:
function OnClick(clickData)
{
var dlg = clickData.func.Dlg;
dlg.title = "Search Tab";
dlg.message = "Enter part of the tab's path or name:";
dlg.buttons = "OK|Cancel";
dlg.icon = "question";
dlg.max = 256;
dlg.input = "";
// Show the dialog
var result = dlg.Show();
if (result != 1 || dlg.input.trim() == "") {
DOpus.Output("Search was canceled.");
return;
}
// Store the entered text in a variable
var searchQuery = dlg.input.trim().toLowerCase();
var found = false;
// Iterate through all Listers
var listers = DOpus.listers;
for (var eListers = new Enumerator(listers); !eListers.atEnd(); eListers.moveNext()) {
var lister = eListers.item();
DOpus.Output("Found Lister: " + lister.title);
// Iterate through the tabs in the current Lister
for (var eTabs = new Enumerator(lister.tabs); !eTabs.atEnd(); eTabs.moveNext()) {
var tab = eTabs.item();
var tabLabel = tab.label.toLowerCase();
// Check for matching tab label
if (tabLabel.indexOf(searchQuery) !== -1) {
tab.selected = true;
DOpus.Output("Tab '" + tab.label + "' was found and activated.");
found = true;
return; // Stop when the first match is found
}
}
}
if (!found) {
DOpus.Output("No tab with a name containing '" + searchQuery + "' was found.");
}
}
Maybe you can not set the dlg.input property. The manual only states you can retrieve the value the user did input.
Edit : you can also try to put some DOpus.Output
along the way to narrow down the instruction that fails since it doesn't seem explicit from what you say.
Always good to say which line has the error when asking for scripting help.
It seems to be the call to trim()
, which isn't surprising because the Windows JScript implementation doesn't support String.trim()
by default.
You can add it, however:
String.prototype.trim = function()
{
return this.replace(/^\s+|\s+$/g, '');
};