Working With The Script Editor

   Print  Previous  Next

Introduction

The editor that is an integrated part of MADRIX allows to create new MADRIX Scripts and binary scripts. Or you can edit existing ones. Of course, you can load and save a script and start or stop its execution.

 

The Script Editor Window

In the upper area of the editor, the menu bar for the most common commands is located. In the main window below, you can enter the source code. A script can also write texts to the output window, the Script output. The Compiler Messages box is hidden by default. It can be used to  read compiler messages, such as errors and warnings.

The position of each window can be customized by dragging their title bars. Toolbar, Script output, and the Compiler Messages box can be shown or hidden using the menu entry "View".

Script Editor Screenshot

The Script output starts empty, every time you compile a script. In order to delete the messages manually, please choose in the menu item "Edit" the point "Clear Messages". It is also possible to clear the output of the compiler via "Clear Compiler Messages", located in the same menu.

The Script editor supports syntax highlighting which will help you to read the source code, distinguish different types of phrases (e.g. comments, data types) and find errors. Furthermore, the code structuring is enhanced since every line is automatically indented like the last line.

 

Working with Scripts

Scripts, it does not matter if macros or scripts for the MAS Script effect, are stored together with the effect. Hence, they always form part of a setup or an effect that is saved. Furthermore, it is possible to save scripts to files in order to share them with others. Another way is to save a script as a compiled script. This is a script which does not contain any source code, but only the runtime code. This means that with the help of compiled scripts it is possible to share scripts, but to let the source code remain a secret at the same time.

Creating, Loading, and Saving Scripts

New, Load, Save

To create a new script please choose in the menu item "File" the point "New". Now, the basis for a new script is generated. It consists of some templates for the script's meta data and several default functions. You can edit the new script now.

If you want to save the script, please choose in the "File" menu "Save" or "Save as ...". The latter opens a dialog for you to enter a new file name for the script and to save it in a new file. The ending of the file will be .mas. If the file already exists, you have to confirm or cancel the saving process. When confirming, the file will be overwritten.

When loading a script with the menu item "File" > "Open", MADRIX automatically starts the compilation of the source code, but the script will not start by itself. Alternatively, you can use the "Load" button in the interface of the MAS Script effect, which does not exist for Effect Macros or the Main Output Macro. Then, an (error-free) script will run instantly.

Compiling and Executing Scripts

Compile, Play, Stop

Before a script can be run, it needs to be compiled. While compiling the script, it is analyzed and translated into the binary format MADRIX works with internally. To compile your script, choose "Compile" in the menu "Compile" (or press F5). After the script was compiled successfully, it will be executed automatically. If the compilation fails, the script cannot be executed. An error message will be displayer. Just double-click on the message and the cursor will jump to the referred position. In addition, the line number is printed with each compiler message.

The execution of a script can be interrupted and continued by using the "Stop" and "Run" item in the menu "Compile". The buttons are also available in the toolbar.

Using Compiled Scripts

A script can also be saved as a compiled script. You can find the function "Compile and Save" in the menu "Compile" or use the shortcut F6. After a successful compilation, a dialog will be opened in which you can enter a name for the compiled script.

Because a compiled script does not contain any source code, only the script's meta data will be displayed in the window when you load such a kind of file. You (or others) will not be able to edit the code.