Data OPerators (or DATs) are used to hold text data like strings, scripts, and XML. DATs either contain multiple lines of text as in a script, or a table of rows and columns of cells, each containing one string.
DATs for Scripting
DATs can be linked together to select, re-arrange and evaluate data and expressions, making DATs a powerful procedural scripting tool.
DATs that contain scripts can be triggered by events like mouse clicks and any operation of gadgets in TouchDesigner control panels. DAT scripts can also be triggered by channel changes in CHOPs.
- Script Example: This will create a button that plays a sound when you click it: Create a Button component (Tab -> COMP -> Button). Go inside it (Enter) and create an Audio Play CHOP (Tab -> CHOP -> Audio Play).
- Then create a Text DAT (Tab -> DAT -> Text) and make its Viewer Active. Then click in its viewer and type in the text "
audioplay audioplay1 0". Click outside the node to end text entry. Change the DAT's "Execute" menu parameter to "On Panel Change". Go back up (u), make the button's Viewer Active. click on the viewer of the button. It should make a Notify sound.
You can also run a script in a Text DAT by using the "
run" command from the textport or another DAT.
DATs for Tables
DAT tables are rows and columns of cells containing text strings.
You can use table DATs to export to parameters. See DAT Export.
DAT tables can be modified with the
Table cells are read with a
tabrc() expression. See Help -> Commands and Expressions.
- Table Example: This will create two TOP images with names in it: Create a Table DAT (Tab -> DAT -> Table). Make its Viewer Active. Right-click on the viewer and select Add Column, and then Add Row, and again Add Row, which should give you 3 rows and 2 columns of empty cells (or put 2 and 3 in the parameters.)
- Click in the top left cell and type
name, top right type
age, and fill in the remaining cells with
- Now create a Text TOP (Tab -> TOP -> Text) and in its parameter called Text, type this expression to retrieve a cell from the table:
`tabc("table1", $OD, "name")`. You should see "joe" in the Text TOP viewer. Copy/paste the Text TOP (Ctrl-C, Ctrl-V). The new TOP should be called
text2and its viewer should say "jane".
tabc()expression gets from the table,
table1, the node you edited. It gets from the column called
name. And the row is
$OD, which is a variable you can use in any node that means "operator digits", the digits at the end of the operator name, which in this case is
- In the TOPs' expressions, you can replace
DATs for manipulating Web and XML Data
DATs for Raw Text
DATs can also be use to hold raw text, such as pop-up help messages for panel gadgets.