> For the complete documentation index, see [llms.txt](https://chaoses-ib.gitbook.io/directory-opus/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chaoses-ib.gitbook.io/directory-opus/manual/scripting/script_functions.md).

# Script Functions

\*Script Functions \*are [defined directly in a button or menu](/directory-opus/manual/customize/creating_your_own_buttons.md) - they provide a third type of button function alongside *Standard Function* and *MS-DOS Batch Function*.

![](https://3597805814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3XSZSwWow0fDf6fQJobd%2Fuploads%2Fgit-blob-5bad69ea7ca92c76bc67ebfd1a72008ea7111ff3%2Fscript_function.png?alt=media)

The screenshot above is an example of a script function that selects all "high-definition" images in the current source file display (which are defined as images with a vertical resolution greater than or equal to 1080 pixels).

The dropdown at the top of the script editor is used to specify the scripting language - here it is set to *VBScript.* The **Default** button lets you save a script “template” as the default for a particular language, and revert to the default at any time.

The [**OnClick**](/directory-opus/manual/reference/scripting_reference/scripting_events/onclick.md) function is a defined script entry point that Opus will call whenever your button is clicked (or hotkey is pressed). The [**ClickData**](/directory-opus/manual/reference/scripting_reference/scripting_objects/clickdata.md) object passed to it provides a number of properties and methods that you can use to interact with the Lister that launched the function.

When the function editor has been set to run a *Script function*, it has three separate tabs which split the function into:

* **Modifiers**: Any [command modifiers](/directory-opus/manual/customize/creating_your_own_buttons/command_modifiers.md) that apply to the script (e.g. **@filesfromdroponly**).
* **Script Code**: The actual code that defines the script.
* **Resources**: Script [resources](/directory-opus/manual/scripting/resources.md).

At the bottom of the function editor the **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 below the editor which displays any errors or script text output.

The **Resources** tab defines any [resources](/directory-opus/manual/scripting/resources.md) 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.

![](https://3597805814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3XSZSwWow0fDf6fQJobd%2Fuploads%2Fgit-blob-1ddb91586d63b9aa7e2316d04759dd98ee11509e%2Fimage063.png?alt=media)

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](/directory-opus/manual/scripting/script_editor/editors/dialog_editor.md).
