Tool Script
Tool script, is a just a script that does not register any events (callbacks) and exists immediately after execution.
If you have written tool script you can call it directly using Tools→Execute or you can plug it into UI same way as you do for external tools.
If plugging it as an external tool, everything is straight forward:
- In Manage Tools dialog you create new tool.
- In tool properties select as command path to your tool script.
- Add some icon, give nice title etc
- Add arguments (not really needed, while script can access all variables with scripting, but implemented for convenience)
- Assign shortcut, if you want one
- Catch Output is by default On because if you write in Output with tool, it automatically caught by HippoEDIT
- Select where you want to see your tool: in Tools menu, in Context menu, in Tools toolbar
- Done.
The tool script below will write script arguments and selected text from current view into Output pane:
- tool.js
#include "he_utils.js" // from here ax2js comes #include "he_edit.hejs" // and from here GetSelectedText helper var arguments = ax2js(ScriptArguments); Output().write(ScriptName + " is executed with arguments : "); for (i = 0; i < arguments.length; i++) Output().write(arguments[i] + " "); Output().writeln(); // insert line break after last command line parameter if ( ActiveDocument != null ) { Output().writeln(ActiveDocument.Path); Output().writeln(GetSelectedText(ActiveDocument.ActiveView)); }
The output:
C:\temp\tool.js is executed with arguments : C:\temp\tool.js C:\temp\tool.js ActiveDocument != null