Macros Dialog

From Derivative
Jump to: navigation, search

MacrosDialog.jpg

Description
[edit]

The Macros dialog lets you add, edit, and delete Macros. Macros managed through this dialog are Root macros and are saved in the network location /local/macros.

Macros
[edit]

The macros are listed in the dialog with the macro name in the left column, and the macro command in the right column. If the macro is a multiple line command script, then just the first line of the script is displayed in the command column.

When there are more than 20 macros in the list, use the scroll bar on the right side to look through them.

MacrosTitlebar.jpg

The dialog's titlebar can be grabbed to drag the dialog around the screen. To close the dialog, click the x button in the upper-right corner.

Adding a Macro
[edit]

MacroAdd.jpg

The text fields at the top of the dialog are used to add macros. Enter the name of the macro in the name field on the left, then enter the command in the field on the right. Then click the Add button to add the macro, it will be displayed in the list below.

If the macro is a multiple line command script, add the macro after entering the first line of the script in the command field. Once created and displayed in the list, right-click the macro and select Edit Macro in Text Editor from the options menu. It can be helpful to describe the macro's usage in comments on the first line of the script, since the macro list in the dialog only shows the first line of multiple line scripts.

For example: macroname      #USAGE: macroname objectpath materialpath

Editing a Macro
[edit]

MacroEdit.jpg

To edit a macro's name, click in the name field and change the name. The name is updated after pressing Enter or clicking in another field.

To edit the macro command(s), there are 2 options.

  1. If the macro is a single command, click in the command field and update it. The command is updated after pressing Enter or by clicking in another field.
  2. If the macro is a multiple line script, right-click the macro and select Edit Macro in Editor from the options menu. This opens the script in an external text editor. The script is updated when the external editor is saved and closed.

Passing Arguments to a Macro
[edit]

If your macro is called add, and if the user types add 15 8, you want it to add two numbers and print the result 23, then define the add macro to be echo `$arg2 + $arg3`.

If you want your macro to call a script in a DAT at /project/adder, put in the DAT: echo `arg1 + $arg2`. and define the macro to be: run /project/adder $arg1 $arg2.

Options Menu
[edit]

Right-click on any macro to open the options menu.

MacroOptionsMenu.jpg

Run Macro
[edit]

Runs the macro script.

Edit Macro in Text Editor
[edit]

Open the macro for editing in an external text editor.

Delete
[edit]

Deletes the Macro.

A Tscript-only script that executes one or more scripting language commands. The F1 to F12 keys run macros. The F1 macro puts you in Perform Mode. See also Script, DAT and Python.

An Operator Family that manipulates text strings: multi-line text or tables. Multi-line text is often a command Script, but can be any multi-line text. Tables are rows and columns of cells, each containing a text string.