You can include other scripts within your script:
a = 5
The Info window will show the result 25 if the file square.praat is as follows:
a = a * a
The inclusion is done before any other part of the script is considered, so you can use the form statement and all variables in it. Usually, however, you will put some procedure definitions in the include file, that is what it seems to be most useful for. Watch out, however, for using variable names in the include file: the example above shows that there is no such thing as a separate name space.
Since including other scripts is the first thing Praat will do when considering a script, you cannot use variable substitution. For instance, the following will not work:
scriptName$ = "myscript.praat"
#This will *not* work:
#That did *not* work!!!
You can use full or relative file names. For instance, the file square.praat is expected to be in the same directory as the script that says include square.praat. If you use the ScriptEditor, you will first have to save the script that you are editing before any relative file names become meaningful (this is the same as with other uses of relative file names in scripts).
You can nest include files, i.e., included scripts can include other scripts. However, relative file names are always evaluated relative to the directory of the outermost script.
The include statement can only be at the start of a line: you cannot put any spaces in front of it.
© ppgb, April 7, 2013