# Script Functions

\*Script Functions \*are [defined directly in a button or menu](../customize/creating_your_own_buttons) - 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**](../reference/scripting_reference/scripting_events/onclick) function is a defined script entry point that Opus will call whenever your button is clicked (or hotkey is pressed). The [**ClickData**](../reference/scripting_reference/scripting_objects/clickdata) 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](../customize/creating_your_own_buttons/command_modifiers) that apply to the script (e.g. **@filesfromdroponly**).
* **Script Code**: The actual code that defines the script.
* **Resources**: Script [resources](resources).

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](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.

![](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](script_editor/editors/dialog_editor).
