Thanks for adding the very useful FindWindow() Evaluator function!
Can you add an Run() Evaluator function for use in the Script Modifiers section that can be used with syntax that looks similar to this:
@eval: =Run("userCommand_Or_ScriptAddIn")
@eval: returnVal=Run(cmdStrVar)
@sync: @eval returnVal=Run(cmdStrVar)
Among other things, a Evaluator function like Run() would make possible:
Ability to pre-process button scripts with existing user commands.
Ability to call external commands embedded in the scripts.
Ability to react to a toolbar button menu dropdown click action.
Even though there may be performance concerns, I believe that some things run so quickly in Directory Opus that it would be negligent except for unusual scripts.
Can you let me know if this is already possible or if I missed something?
Thanks, but when I try to call a user command from a JScript's Modifier section, it is ignored. Am I doing something wrong?
Here is the button content:
Either I don't understand or it is not working the way you suggest.
Recall I want to invoke a user command from the Modifiers section of a button with JScript.
@Leo Can you show me a working example of the syntax?
I tried placing my user command in the Script Modifier section like shown above.
Here's what I tried:
=UserCommand1
="UserCommand1"
As you can see in my previous post, UserCommand1 is a JScript that runs a DOpus.Output statement.
As Leo mentioned above, you don't need the @eval modifier for building a command line. Just start with '=' and the return value from the evaluation expression will be executed.
Example: = return "ToolbarPalette FORCEEXEC" + (KeyDown("shift") ? " FORCERELOAD" : "");
this will run ToolbarPalette FORCEEXEC. If you press the shift key, it will also include the FORCERELOAD argument.
Retrieving a value from a command is a bit trickier. I haven't tried it myself, but my guess is that if your command can somehow set a global variable, you could later access that variable via Evaluator.
My need is to run a User Command within a Modifier such as @eval, @enableif, @label.
This is because my User Command performs work that affects button state.
This is the reason I initially requested (at top of this post) an Evaluator function called Run().
Just a guess, but could it be because your UserCommand sets global variables? User commands generally don't 'return' values, so there would be nothing to evaluate.
If that's the case, would running the command and then querying the variables it sets could be what you're looking for?
Maybe a real example could shed more light on this...
That could work. While I have been able to set variables on a timer basis I prefer to call the user defined command only during a UI Refresh (which is when the @eval: runs). So ideally, the following would work if an Evaluator run() function could be added by GPSoft:
If your command is setting variables or changing the UI state, then running the command (normally), and then querying the variables or state it sets should work.
In addition to the aforementioned attempts, today I also tried adapting a virtual file system plugin as a way to run my script from the Modifiers section. After building a vfs sandbox, this is what i used:
// JScript - vfs sandbox Log file proves call to vfs sandbox occurs:
var fsutil = DOpus.FSUtil;
var items = fsutil.Exists("gary://FOO_123_JSCRIPT");
DOpus.Output(items);
// CLI - vfs sandbox Log file proves call to vfs sandbox DOES NOT occur:
Exists("gary://Foo_123_EVAL")
// Modifiers section of a button using JScript.
// vfs sandbox Log file proves call to vfs DOES NOT occur:
@eval: test=Exists("gary://FOO_123_JSCRIPT")
@enableif:test
So I am giving up on getting a Dopus UserCommand to execute from the Modifiers section of a button having Jscript code.