Scripts have always been able to display simple dialogs (e.g. Yes/No style requesters, or a dialog letting you enter a simple string or choose an item from a list). In Opus 12 scripts are now able to define free-form dialogs in much the same way that “proper” Windows software can, using many of the standard Windows controls.
Above is an example of the type of dialog that scripts can now create. Dialogs are defined as “resources” – XML formatted data that defines the dialog and control layout. Any script can have resources attached – either a script in a button, or one in the Script Add-Ins folder.
A full GUI-based dialog editor is provided inside the function editor, which makes it very easy to design script dialogs.
When the function editor has been set to run a Script function, it now has three separate tabs which split the function into:
Modifiers: Any command modifiers that apply to the script (e.g. @filesfromdroponly).
Script Code: The actual code that defines the script.
Resources: Script resources.
The script type (language) is now set using the Script Type drop-down in the toolbar – you don’t need to type the @script line explicitly any more. The Default button lets you save a script “template” as the default for a particular language, and revert to the default at any time.
At the bottom of the function editor a new Run button lets you test the current script immediately, without having to exit Customize mode. When you use the Run button an output panel will appear (shown above) which displays any errors or script text output.
The Resources tab defines any resources available for the script to use. Dialogs are the main type of resource, but also supported are string resources which let you define strings in multiple languages.
While you can hand-code dialog resources in XML if you wish, it’s much easier to design them using the in-built dialog editor. To create a new dialog using the editor, click the Dialogs drop-down and choose the New Dialog command. You can also edit existing dialogs by selecting them from the drop-down list.
The dialog editor and how to use dialogs from scripts is explained in detail in the reference section.