- Open a lister and a standalone viewer.
- Create a JScript button in the viewer with the following code:
DOpus.Output('outside OnClick()'); function OnClick(clickData) { DOpus.Output('inside OnClick()'); DOpus.Output(clickData.func.viewer.current); }
- Everything works.
- Create a user command
BugRepro
using the customize-dialog with the same JScript code as above and run it via"C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe" /cmd:viewer BugRepro
- Everything works.
- Create a button in the lister with the following code:
function OnClick(clickData) { var cmd = clickData.func.command; cmd.SetType("script"); cmd.AddLine("@script JScript"); cmd.AddLine(" \n\ DOpus.Output('outside OnClick()'); \n\ \n\ function OnClick(clickData) { \n\ DOpus.Output('inside OnClick()'); \n\ DOpus.Output(clickData.func.viewer.current); \n\ } \n\ "); DOpus.viewers.lastactive.Command(cmd); }
- Bug:
outside OnClick()
is the only text that's printed, meaningOnClick()
isn't called. When you run JScript code with thatCommand
approach in a lister instead of a viewer, though (i.e., not usingViewer.Command()
, but justRun()
),OnClick()
is called.
- Bug:
Is there a reason you have one script generating another script which it then runs, rather than just doing everything in the first script?
We've never envisaged the command object being used in that way.
This is essential to the implementation of my Talon voice command set that uses DOpusRT.exe
to send commands to DOpus. But DOpusRT.exe
only supports a single standard command, not multiple, no conditions, no JScript code. And with .dcf files, you can only send code to the source lister, which is unlike DOpusRT.exe
's /cmd:active,thisdesktop
. So, I had to implement a script add-in ("the first script", as you call it) that adds the custom command RunBareCommandFile
. RunBareCommandFile
receives the path of a script file ("another script", as you call it; extension .std for standard command code, .js for JScript) and must then insert the code into a Command
and execute it. This generally works well: OnClick()
is executed in bare command files made for listers. Only OnClick()
in bare command files made for viewers doesn't work.
I'm wondering why you added Command.SetType()
then, which I call with the argument "script"
for .js files.
That's fixed for the next update.