Subsections

B.4.8 scripts

This will cause the interpreter to open, close or use a script file.

To start reading commands from a script (indirect command file), use the @ character at the Xselect prompt:

xsel >  @myanalysis.xco

To open a script file for keystroke recording, give the command

xsel >  script <script file>

where $<$script file$>$ is the name of the file to be opened (default extension is .xco). If $<$script file$>$ matches the string “none” then the current script file is closed. The script contains a list of the commands executed – to get a complete dump of the session use the log command.

Examples:

xsel >  script michelle

will start putting commands into michelle.xco

xsel >  script none

stops recording commands and closes the script file.

scripts search path

If you use @filename and the script file cannot be found in the current directory, two other directories are searched for the file. First, a check is made to see if you have defined the environment variable MY_XCOMS. If MY_XCOMS is defined then its translation is prepended to the file name. Thus

setenv MY_XCOMS /users/my_name/my_xcoms

would cause the directory /users/my_name/my_xcoms to be searched for the specified file.

scripts parameters

It is possible to use parameters with scripts. To do this you enter the parameters on the line where you started the script. Thus,

xsel >  @test one two three

would cause the test script to be read using three parameters one, two, and three. When the script is being read, %n% is replaced with parameter n. Thus, %1% will be replaced with one, %2% with two, etc. The following illustrates a script that expects to be run with parameters:

make obs %1% choose %2% ...bin %3%

If you forget to enter the three parameters, then %n% is replaced with a null string.

It is possible for a script to call another script and pass in parameters. Thus,

@deeper first %2% %3%

is a valid line in a script. In this example, the first parameter is first, whereas the next two parameters will be set equal to parameters 2 and 3 of the current script. Also quotes can be used to denote a single parameter with embedded spaces, or other magic characters.

returning to the terminal

A line containing @ on its own stops the script (and any scripts that called it) and returns control to the terminal.