I want to "modernize" some of my custom buttons with own GUIs, but not good in scripting. So I first used an example script from manual for MP3-encoding, but got error in run.command:
function OnClick(clickData) {
var Dlg = DOpus.Dlg;
Dlg.window = clickData.func.sourcetab;
Dlg.template = "dlg";
var retVal = Dlg.Show();
cmd.RunCommand('/dopusdata\User Data\Lame\Lame.exe' +retVal '{filepath$}');
}
"retVal" is choosen compression value, error is
')' erwartet (0x800a03ee)
Parsefehler - Skript abgebrochen
Leo
February 13, 2022, 10:31am
2
Looks like there's a missing +
after retVal
.
lxp
February 13, 2022, 10:38am
3
I see trouble coming from missing quotes, spaces, and unescaped backslashes.
1 Like
Still got an error. Here's the full code (once it will work I am able to rewrite all my buttons on my own :-)):
<resources>
<resource name="dlg" type="dialog">
<dialog fontsize="8" height="50" lang="" title="MP3 encoden" width="180">
<control halign="left" height="8" name="static1" title="Bitte MP3-Qualität auswählen:"
type="static" width="100" x="42" y="9" />
<control close="1" default="yes" height="14" name="-b 320" title="320 kbps"
type="button" width="50" x="9" y="30" />
<control close="2" height="14" name="-b 160" title="160 kbps" type="button"
width="50" x="66" y="30" />
<control close="3" height="14" name="-b 128" title="128 kbps" type="button"
width="50" x="122" y="30" />
</dialog>
</resource>
</resources>
function OnClick(clickData) {
var Dlg = DOpus.Dlg;
Dlg.window = clickData.func.sourcetab;
Dlg.template = "dlg";
var retVal = Dlg.Show();
cmd.RunCommand('/dopusdata\User Data\Lame\Lame.exe' + retVal + '{filepath$}');
}
lxp
February 13, 2022, 10:54am
5
You'll find bugs much more quickly and avoid side effects, if you split the command like this:
cmd.RunCommand('Set UTILITY=otherlog');
DOpus.ClearOutput();
var cmdLine = 'GO PATH="' + srcPath + '"';
DOpus.Output(cmdLine);
// cmd.RunCommand(cmdLine);
2 Likes
I still don't get the exe to be executed (not defined):
cmd.RunCommand('"//dopusdata\\User Data\\Lame\\Lame.exe"');
Leo
February 13, 2022, 3:51pm
7
In JScript, the /
shouldn’t be doubled, only the \
.
Thanks, in default jscript button it works, in my cmd still got error "cmd not defined"? I don't get it.
lxp
February 13, 2022, 4:11pm
9
Something like
var cmd = clickData.func.command;
is missing.
Thank you very much, lxp, it works. As said, I am no developer.
Now I just need to get variable "value" implemented, what do I wrong here?
cmd.RunCommand('"/dopusdata\\User Data\\Lame\\Lame.exe"' +value+ '{filepath$}');
lxp
February 13, 2022, 5:07pm
11
Probably missing spaces around value
.
Maybe post the button as xml, so we have to guess less.
Attached, thanks.
And at least I need one example how to set button close to a value (here: close 1 = -b 320, close 2 = -b 160, and so on).
<?xml version="1.0"?>
<button backcol="none" display="icon" textcol="none">
<label>_SC_Testbutton</label>
<icon1>#usercommand</icon1>
<function type="script">
<instruction>@script JScript</instruction>
<instruction>function OnClick(clickData) {</instruction>
<instruction> var Dlg = DOpus.Dlg;</instruction>
<instruction> Dlg.window = clickData.func.sourcetab;</instruction>
<instruction> Dlg.template = "mydlg";</instruction>
<instruction> var retVal = Dlg.Show();</instruction>
<instruction> var cmd = clickData.func.command;</instruction>
<instruction> cmd.RunCommand('"/dopusdata\\User Data\\Lame\\Lame.exe"' +"retVal" + '{filepath$}');</instruction>
<instruction>}</instruction>
<instruction> </instruction>
<instruction />
<instruction />
<instruction>==SCRIPT RESOURCES</instruction>
<instruction><resources></instruction>
<instruction> <resource name="mydlg" type="dialog"></instruction>
<instruction> <dialog fontsize="8" height="123" lang="german" title="MP3 encoden" width="142"></instruction>
<instruction> <control halign="left" height="8" name="static1" title="Bitte Qualität auswählen:" type="static" valign="top" width="83" x="33" y="9" /></instruction>
<instruction> <control close="1" height="14" name="button1" title="CBR 320 kbps (Beste)" type="button" width="92" x="28" y="29" /></instruction>
<instruction> <control close="2" height="14" name="button2" title="CBR 160 kbps (Medium)" type="button" width="92" x="28" y="47" /></instruction>
<instruction> <control close="3" height="14" name="button3" title="CBR 128 kbps (Web/Mail)" type="button" width="92" x="28" y="65" /></instruction>
<instruction> <control close="4" height="14" name="button4" title="VBR ~220 kbps (Beste)" type="button" width="92" x="28" y="83" /></instruction>
<instruction> <control close="5" height="14" name="button5" title="VBR ~165 kbps (Medium)" type="button" width="92" x="28" y="101" /></instruction>
<instruction> </dialog></instruction>
<instruction> </resource></instruction>
<instruction></resources></instruction>
</function>
</button>
lxp
February 13, 2022, 5:47pm
13
Here you go.
function OnClick(clickData) {
var cmd = clickData.func.command;
var dlg = clickData.func.Dlg();
dlg.window = clickData.func.sourcetab;
dlg.template = 'mydlg';
var retVal = dlg.Show();
if (retVal == 1) var encVal = '-b 320';
if (retVal == 2) var encVal = '-b 160';
if (retVal == 3) var encVal = '-b 128';
if (retVal == 4) var encVal = '-V ...';
if (retVal == 5) var encVal = '-V ...';
var cmdLine = ('"/dopusdata\\User Data\\Lame\\Lame.exe" ' + encVal + ' "{filepath$}"');
DOpus.Output(cmdLine);
cmd.RunCommand('dopusrt /argsmsgbox ' + cmdLine);
// cmd.RunCommand(cmdLine);
}
Big thanks, lxp. It works and with this example I can create a nicer GUI for all my other audio-buttons!
One last question, if I add a radio button, how to get its value?
Leo
February 13, 2022, 7:27pm
16
Reading Dialog Control Values in the manual shows how to get a value from a control.
1 Like
The manual explains return value for button (close value), but there's no such value for radiobutton.
Leo
February 14, 2022, 12:54pm
18
It explains both. The control.value property tells you if a radiobutton is on or off.
1 Like
Ah, ok. Sorry for my ignorance in scripting.
Hi Sasa I have interest in your audio buttons. Can you tell me what does this button does?