Scripts inside DATs
The contents of any DAT can be run as a script. This can be run manually by right-clicking on the DAT and selecting Run Script or by various triggers that can be setup in DATs.
Contents |
Creating and Editing a Script
The Text DAT is the easiest way to start writing a script. Simply double-click on the Text DAT's node viewer and start writing the script. The script can be edited in the Textport by dragging a DAT to the Textport and selecting Open DAT from the pop-up menu. Any DAT script can also be edited in an external editor by right-clicking on the DAT and selecting Edit Contents... from the menu.
You can run the script with the run Command or the include Command.
You can read an external text file into DATs using the File In DAT. This can then be connected to the input of a Text DAT and then run like any script in a Text DAT, or triggered by one of the various methods mentioned below.
Right-click and select Run Script at any time to test the script.
Triggering a Script in DATs
The Panel Execute DAT triggers the script held in the DAT by listening for a Panel Component's value change.
The CHOP Execute DAT triggers the script held in the DAT by listening for a CHOP channel's value change.
The DAT Execute DAT triggers the script held in the DAT by listening for a table DAT cell's value change.
The Parm DAT can be connected to a DAT network to trigger the script by changes in a specified parameter.
The Execute DAT runs when events occur like the .toe startup, a .tox file being created and more.
The OP Execute DAT can be connected to trigger the script by changes to an operators state, triggering on such things as node deleted, flags changing, name changed, etc.
Expressions
The Evaluate DAT will take strings and expressions and evaluate the contents. The input can be text or table format.
Directing the Output of a Command to a DAT or File
All commands can output their text to a DAT.
opstats >statdat
This command will take the output of an opstats command and place it in a new or existing DAT called statdat.
The > indicates that Touch should take the text generated by the command and instead of printing in the textport, put the results in a DAT called statdat.
All commands take a -T option that will put the command output in a Table DAT, and the format may be changed to be more useful in tables.
Here we take the table-formatted output of the opstats and lc commands and place them in a new or existing DATs.
opstats -T >statdat lc -l -T >lcdat
>> will append the text to the existing text in a DAT.
lc >>statdats
To send the output to a file in the file system, use this syntax:
opstats -T FILE>statdat
