> 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_dialogs/the_dialog_message_loop/simple_dialogs.md).

# Simple Dialogs

With the simple method, the script is not responsible for the dialog’s message loop. Instead, the script prepares a [**Dialog**](/directory-opus/manual/reference/scripting_reference/scripting_objects/dialog.md) object, and invokes the **Show** method to display the dialog. The **Show** method doesn’t return until the user has closed the dialog, at which time you can read the values of any controls on the dialog to find out what data the user provided.

To allow the user to close the dialog you should add one or more *Button* controls with the **Close Dialog** property set to **True**. The return value of the **Show** method will be the value you specified for the button’s **Return Value** property.

Below is an example of a script that displays a dialog using the simple method. The raw XML for the dialog is also included. If you want to experiment with this example, create a new toolbar button, and paste the script code into the **Script Code** tab of the command editor, and the resources XML into the **Resources** tab. All the following examples are written in VBScript.

### Script Code - VBScript

```
Function OnClick(ByRef clickData)
  Set Dlg = DOpus.Dlg
  Dlg.window = clickData.func.sourcetab
  Dlg.template = "testdlg"
  retVal = Dlg.Show
  DOpus.Output "Return code = " & retVal
End Function
```

### Script Code - JScript

```
function OnClick(clickData) {
  var Dlg = DOpus.Dlg;
  Dlg.window = clickData.func.sourcetab;
  Dlg.template = "testdlg";
  var retVal = Dlg.Show();
  DOpus.Output("Return code = " + retVal);
}
```

### Resources

```
<resources>
  <resource name="testdlg" type="dialog">
    <dialog fontsize="8" height="58" lang="" title="Test!" width="180">
      <control halign="left" height="8" name="static1" title="Test Dialog"
               type="static" width="35" x="72" y="9" />
      <control close="1" default="yes" height="14" name="button1" title="One"
               type="button" width="50" x="9" y="30" />
      <control close="2" height="14" name="button2" title="Two"
               type="button" width="50" x="66" y="30" />
      <control close="3" height="14" name="button3" title="Three"
               type="button" width="50" x="122" y="30" />
    </dialog>
  </resource>
</resources>
```

This script creates and displays the following dialog:

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

In the script, the [**Dialog**](/directory-opus/manual/reference/scripting_reference/scripting_objects/dialog.md)**.Show** method is called on the *Dlg* object, and its return value (*retVal*) corresponds to the button you click in the dialog. The value is then printed to the script output log.

When the **Show** method returns your script can read the value of any controls it may have added to the dialog – see the [*Reading Dialog Control Values*](/directory-opus/manual/scripting/script_dialogs/reading_dialog_control_values.md) page for an example of this.

&#x20;


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://chaoses-ib.gitbook.io/directory-opus/manual/scripting/script_dialogs/the_dialog_message_loop/simple_dialogs.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
