DAT
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.
Contents |
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.
The DAT whose name is Table DAT is used to define new tables. To manually add, delete rows and columns of tables, press RMB over the table when Viewer Active is on and select from the menu.
The tables are then manipulated by the Select DAT, Evaluate DAT, Merge DAT, Switch DAT, Sort DAT and others.
You can use table DATs to export to parameters. See DAT Export.
DAT tables can be modified with the tabcell command.
Table cells are read with a tab(), tabr(), tabc() or 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 typeage, and fill in the remaining cells withjoe,9,jane,21.
- 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 calledtext2and its viewer should say "jane".
- That
tabc()expression gets from the table,table1, the node you edited. It gets from the column calledname. 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 is1and2fortext1andtext2.
- In the TOPs' expressions, you can replace
"name"with"age".
DATs for manipulating Web and XML Data
The Web DAT gets HTML or other data by passing a URL to the internet and receiving a response. The result and any XML data can be filtered with an XML DAT, then further processed with the other DATs.
DATs for Raw Text
DATs can also be use to hold raw text, such as pop-up help messages for panel gadgets.
| ||||||||||||||

