Hi,
in DOpus 11.1 Beta 2, I want to write a script for copying some specific files from several folders. In the first dialog I added a checkbox that lets me choose if I want to open a new lister for this or if I prefer to use the current one.
Everything works if I use a new lister or if I use the current one when it already is in dual-display mode. If I want to use the current lister and it is not yet in dual-display mode when starting the script, I have difficulties to get the destination tab under control after switching to dual-display mode in the script using
clickData.func.command.RunCommand('Set DUAL=horiz,dest');
Using
clickData.func.desttab.Update();
leads to an error message in the log:
(translated from German).
clickData.func.command.SetDestTab(clickData.func.command.results.newtabs(0));
leads to the error message
("out of bounds"?).
When I use
clickData.func.command.SetDest(mainIconDir);
(with mainIconDir being a path) I can not access the contents of the tab with
var enumDirs = new Enumerator(clickData.func.desttab.dirs);
I then get the error message
I even tried
clickData.func.command.SetDestTab(clickData.func.sourcetab.lister.desttab);
but with the same result.
Well, how can I control the destination tab? I doesn't seem to exist in the single-display lister, but it also doesn't seem to be created in a way that makes it accessible via clickData.func.command.results.newtabs(0).
Here's a part of the script (it doesn't do anything yet, and I'm still experimenting with the new scripting interface, so some things might not be perfect ):
[code]@script jscript
function OnClick(clickData) {
var dialog = DOpus.Dlg();
dialog.window = DOpus.listers[0];
dialog.icon = 'question';
dialog.title = 'Auswahl der Iconset-Sammlung';
dialog.message = 'Bitte wählen Sie die übergeordnete Iconset-Sammlung aus:';
dialog.buttons = 'OK|Abbrechen';
dialog.choices = DOpus.NewVector(
'Axialis Pure Flat 2013 Toolbar Stock Icons',
'Axialis Ribbon & Toolbar Stock Icons'
);
dialog.selection = 0;
dialog.options(0).label = 'Neuen Lister öffnen'
var dialogResponse = dialog.Show();
if (!dialogResponse) {
return;
}
var axialisDir = 'C:\\Users\\My Name\\Documents\\Axialis Librarian\\Icons';
var mainIconDir = axialisDir + '\\' + dialog.choices(dialog.selection);
var basicIconsDir = mainIconDir + '\\- Basic Icons -';
var chosenIconsDir = basicIconsDir + '\\_Temp';
var openNewLister = dialog.options(0).state;
if (openNewLister) {
clickData.func.command.RunCommand('Go NEW=dualhoriz "' + chosenIconsDir + '" DUALPATH "' + mainIconDir + '"');
} else {
var isDual = clickData.func.command.IsSet('DUAL=on');
if (!isDual) {
clickData.func.command.RunCommand('Set DUAL=horiz,dest');
//clickData.func.command.SetDestTab(clickData.func.command.results.newtabs(0));
//clickData.func.command.SetDest(mainIconDir);
//clickData.func.command.SetDestTab(clickData.func.sourcetab.lister.desttab);
}
clickData.func.command.RunCommand('Set SOURCE=left');
clickData.func.command.RunCommand('Go "' + chosenIconsDir + '"');
clickData.func.command.RunCommand('Go "' + mainIconDir + '" OPENINDUAL=horiz');
}
var dialog = DOpus.Dlg();
dialog.window = DOpus.listers[0];
dialog.icon = 'question';
dialog.title = 'Auswahl des Iconsets';
dialog.message = 'Bitte wählen Sie das Iconset aus:';
dialog.choices = DOpus.NewVector();
if (openNewLister) {
var newLister = clickData.func.command.results.newlisters(0);
var command = DOpus.NewCommand();
command.SetSourceTab(newLister.activetab);
command.SetDestTab(newLister.desttab);
var enumDirs = new Enumerator(newLister.desttab.dirs);
} else {
var command = clickData.func.command;
//clickData.func.desttab.Update();
var enumDirs = new Enumerator(clickData.func.desttab.dirs);
}
enumDirs.moveFirst();
while (enumDirs.atEnd() == false) {
if ('- Basic Icons -' != enumDirs.item().name) {
dialog.choices.push_back(enumDirs.item().name);
}
enumDirs.moveNext();
}
dialog.selection = 0;
var dialogResponse = dialog.Show();
if (!dialogResponse) {
return;
}
var iconsetDir = mainIconDir + '\\' + dialog.choices(dialog.selection);
command.RunCommand('Go "' + iconsetDir + '" OPENINRIGHT=horiz');
command.RunCommand('Select ALLFILES');
command.RunCommand('Set SOURCE=right');
dialog.title = 'Starte Kopieren der Axialis-Icons';
dialog.message = 'Ausgesuchte Dateien im oberen Lister (Destination) markiert, übergeordnetes Iconset-Verzeichnis im unteren Lister (Source) geöffnet?';
dialog.choices.clear();
dialog.selection = 0;
dialogResponse = dialog.Show();
if (!dialogResponse) {
return;
}
var iconsetDirContents = DOpus.FSUtil().ReadDir(iconsetDir, true),
dirItem,
subDir,
iconsetDirLength;
while (!iconsetDirContents.complete) {
dirItem = iconsetDirContents.Next();
if (dirItem.is_dir) {
iconsetDirLength = (iconsetDir + '').length;
subDir = dirItem + '';
subDir = subDir.substring(iconsetDirLength + 1);
DOpus.Output(subDir);
// copy icons using "Select DESTTOSOURCE=noext DESELECTNOMATCH"
}
}
dialog.title = 'Skript beendet';
dialog.message = 'Alle Dateien des Iconsets wurden kopiert.';
dialog.buttons = 'OK';
dialog.Show();
}[/code]
Thanks in advance for any help!
Cheers,
Jan