if I have a command button:
@filesonly
myScriptCommand
I would like to be able to test for the @filesonly condition within the JScript/VBScript command code. Is this possible?
Regards, AB
if I have a command button:
@filesonly
myScriptCommand
I would like to be able to test for the @filesonly condition within the JScript/VBScript command code. Is this possible?
Regards, AB
I think you can't. Does the modifier actually work in conjunction with scriptcommands?
Suggestion: Add a switch to the scriptcommand and change the call to something like:
MyScriptCommand FILESONLY
Yes, that is my Plan B.
Regards, AB
So then - are you asking how to simulate what normally happens with those modifiers if you just handle it as a ScriptCommand option instead?
If so, the Tab object has distinct selected_files and selected_dirs properties you can use depending on which ScriptCommand option is used.
My use case is a generic application finder and launcher script. Some applications only operate on files, hence my question. Adding a FILESONLY switch to the script is a simple solution.
Regards, AB
The files collection given to the script command (ScriptCommandData.func.command.files) should already be correct (e.g. no folders if @filesonly was specified). Are you saying it's not?
I'll append my button code and the test script below. When I run it with one folder and one file selected, output is:
$qnd: Script started successfully
$qnd: cmdline = $qnd
$qnd: selected (1) = C:\Relay\TestFolder
$qnd: selected (2) = C:\Relay\WIP.dop
$qnd: Script completed
Button code is simply:
@filesonly
$qnd
$qnd script:
[code]function OnInit(d){
d.name = "$qnd";
d.desc = "JavaScript testbed.";
d.copyright = "aussieboykie";
d.version = "1.0";
d.default_enable = true;
var cmd = d.AddCommand();
cmd.name = d.name;
cmd.method = d.name;
cmd.desc = d.desc;
cmd.label = d.name;
cmd.template = "";
}
function $qnd(d){
// Output the supplied command line
DOpus.output("cmdline = " + d.cmdline);
// List selected items
var f = d.func.command.files;
for (i = 0; i < f.count; i++) {
DOpus.output("selected (" + (i + 1) + ") = " + f(i));
}
}[/code]
Regards, AB
Looks like a bug
The 11.17.2 (Beta) change list says..
Script commands run from a button with the @filesonly or @dirsonly modifiers will now respect the modifiers for the list of files in the Func object received by the script.
..but the test script I posted above still produces exactly the same result. Reports both files and folders.
Regards, AB
I tried your test script as is and it seemed to work ok to me - only selected files were shown in the log, not folders.
Quite correct. I'm not sure what I did wrong the first time but I have just retried the script now and it works as expected. Thanks for the fix.
Regards, AB