How do I run a script?
From TNT
A quick introduction about how to run a script on TNT
TNT scripts are not more than a text file with a series of instructions to be executed in TNT. The program reads the instructions and executes the actions following the order given the file. Many tasks can be accomplished using regular TNT expressions and commands (e.g. tsave, tchoose, mult, hold, etc.) but the maximum potential of TNT is achieved by using the expressions and commands of its macros language. The steps that should be followed in order to run a script will depend on what instructions are included in the file. If the script only includes instructions to compare the length of the trees in memory it is obvious that before running the script, trees should already be in memory (either because you loaded them from a tree file or because you obtained that trees with any command in TNT.). The author of the script may have included a warning message so you will rapidly notice that you do not have trees in memory. Alternatively if you carefully see the error message given by TNT, you will be able to recognize what the problem was. So, be sure that you know what the script requires before you run it.
Here is an example of a simple script (escripto.run) that only uses regular TNT expressions:
procedure c:\matrix.tnt ; /* opens a file called matrix.tnt !! SHOULD BE DATOS IN EXAMPLE ?! */ randtrees 1 ; /* generates one random tree */ taxname= ; /* the trees kept in memory will be stored using the names given in the matrix */ tsave arbolitos.tre ; /* generates a file to store trees in compact format */ save ; /* saves the trees to this file */ tsave/ ; /* closes the tree file */ quit ; /* quits TNT */
Where should the script be in order for it to execute?
The easiest way to run a script is to place it in the same folder than the datafile (IMPORTANT: always remember that TNT can not handle spaces in the path). GIven that the file containing the script has the extension “.run” it can be executed by simply typing the name of the file (!?without the extension?!).
For example: If matrix.tnt and escripto.run are in C:\: then the script can be run by typing:
escripto <enter>
Arguments
In order to execute, some scripts require arguments. Arguments are strings (values) that follow the name of the script that is going to be run. TNT allows a maximum of nine arguments.
Arguments are used to add flexibility to scripts and to change the settings without altering the script itself. Consider the script jackkniffer.run that performs a jacknifing analysis. This script requires two arguments, the first defines the number of replicates and the second defines the searching algorithm to be used.
Arguments within the script are invoked with the symbol % followed by a number between 0 and 9. %1 is the first argument after the script name, %2 is the second, and so on (%0 means in the same file).
For instance here is a modified version of the script escripto.run that requires two arguments: the first is the number of trees to be generated and the second is the name of the tree file where the trees will be stored.
procedure c:\matrix.tnt ; /* opens a file called matrix.tnt */ randtrees %1 ; /* generates as many trees as indicated in argument 1 (in this case 7) */ taxname= ; /* the trees kept in memory will be stored using the names given in the matrix */ tsave %2.tre ; /* opens a tree file in compact format whose name will be defined in argument 2 (arbolitos.tre in this case) */ save ; /* saves the trees to this file */ tsave/ ; /* closes the tree file */ quit ; /* quits TNT */

