# Embedded functions

There are several internal Opus commands that can cause a new Lister or tab to be opened - the most commonly used of these is **Go NEW** and **Go NEWTAB**. Sometimes, you might want a button or hotkey that opens a new Lister (or tab), and then executes further commands in the context of that new element. This can be achieved quite simply by embedding a function that will be passed to the new element once it has been created.

The embedded function must be surrounded with square brackets - for example, the following command would open a new Lister and put it into thumbnails mode automatically:

```
Go /mypictures NEW
[Set VIEW=thumbnails]
```

More complicated multiple line functions can also be embedded, for example:

```
Go NEW
[
Go /mypictures
Set VIEW=thumbnails
]
```

Additionally, functions can be embedded in a **Go FINDTITLE** command. These functions will be run in **all** existing Listers that match the supplied string. If no matching Listers are found, by default the embedded command will not be run at all - you can use the **RUNEMBEDDEDIFNOTFOUND** argument to cause the function to be run in the current Lister in this situation.

You can also embed functions in several [dynamic button](https://chaoses-ib.gitbook.io/directory-opus/manual/customize/creating_your_own_buttons/editing_the_toolbar/dynamic_buttons) commands - for example, **Go DRIVEBUTTONS**. This lets you define a command that is added to each of the buttons generated by the function. For example,

```
Go DRIVEBUTTONS OPENINLEFT
[
Set FOCUS=Left
]
```

This command would produce drive buttons that open their folders in the left-hand file display, and automatically set the focus to that file display at the same time.

The full list of commands that currently support embedded functions are:

* **Favorites** (dynamic button command)
* **Go NEW**
* **Go NEWTAB**
* **Go FINDTITLE**
* **Go DRIVEBUTTONS** (dynamic button command)
* **Go FTPSITELIST** (dynamic button command)
* **Go FOLDERCONTENT** (dynamic button command)
* **Prefs LAYOUT**
* **Properties SETLABEL** (dynamic button command)
* **Recent** (dynamic button command)
* **Show**


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://chaoses-ib.gitbook.io/directory-opus/manual/customize/creating_your_own_buttons/embedded_functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
