DO SCRIPT command

Executes a secondary script, or an external script, from within an Analytics script.

Syntax

DO <SCRIPT> script_name {<IF test>|<WHILE test>}

Parameters

Name Description
SCRIPT script_name

The name of the script to run. You can run secondary scripts in the Analytics project, or external scripts stored in text files with extensions such as .aclscript, .txt. or .bat.

You can specify a file path to an external script. You must enclose the path in quotation marks if it contains any spaces.

Note

You cannot call a script that is already running. For example, if ScriptA calls ScriptB, ScriptB cannot call ScriptA. ScriptA is still running while it waits for ScriptB to complete.

IF test

optional

A conditional expression that is evaluated one time to determine if the script should be executed. If the condition evaluates to true the script runs, otherwise it does not.

Cannot be used with WHILE in the same command. If both are used, WHILE is ignored when the script is processed. A comment is entered in the log, but the script does not stop executing.

WHILE test

optional

A conditional expression that is evaluated after the script runs to determine if the script should be executed again. If the test evaluates to true the script runs again, otherwise it does not.

Note

If you use WHILE, ensure that your test eventually evaluates to false. If you do not, the script enters an infinite loop. In case of an infinite loop, press the Esc key to cancel script processing.

Cannot be used with IF in the same command. If both are used, WHILE is ignored when the script is processed. A comment is entered in the log, but the script does not stop executing.

Examples

Executing a subscript repeatedly until the input is validated

You have a subscript that gathers user input using a dialog box. It does the following:

  1. Prompts the user for the required values.
  2. Checks the user input.
  3. Sets the v_validated variable to true when the input values are validated.

To ensure that the user enters valid input, you use DO SCRIPT and include a WHILE condition so that the script repeats this command until input is validated. Once the value of the variable changes, the main script moves on to the next command:

DO SCRIPT GetUserInput WHILE v_validated = F

Running a subscript from a shared location

You maintain utility subscripts in a shared location. When you require one of the subscripts during an analysis, you reference it using the full path to the shared location:

DO SCRIPT "C:\My utility scripts\GetUserInput.aclscript"  WHILE v_validated = F

Remarks

Related commands

DO SCRIPT is the equivalent of the DO BATCH command found in scripts created with earlier releases of Analytics.

You cannot include the DO SCRIPT command inside a GROUP command.

Usefulness of an external script

Storing a script externally and calling it from within an Analytics script is useful if you want to reuse the same subscript in different Analytics scripts and projects.

You can store a single copy of the script in one location, and make updates to it in one place, rather than maintaining it in multiple locations.