Testing a Script
You can test a script using the Run command, which is available in the Script Editor toolbar and menu. The run command can execute a specific function in one of your scripts, or an entire script. What the Run command is set to run is called the target.
To select which function in which script the Run command should execute, you must use the Set Target command, which will prompt you to select a script and a function. Once you've done this, every time you use the Run command, it will execute the function you set as your target. If you need to test a different function or script later, you will have to use the Set Target command again to change the target script and function. This allows you to work on and repeatedly test one script or one function at a time when working on a script.
- If you use the Run command without setting a target first, you will be prompted to set a target. The selected target will persist until you use the Set Target command to change it.
- The target script and function is also used by the Debug command.
- To run a script from the global scope rather than running a specific function, you can select <Nothing> as the target function.
- Although you can run a script at the global scope, you cannot create a toolbar button that runs a script at the global scope. Toolbar buttons can only run specific functions within a script. Hence, running a script at the global scope should be done for testing purposes only.
- If you are currently editing the script you want to test, save it by clicking on the Save button underneath the editor.
-
Do one of the following:
- In the Script Editor toolbar, click on the Set Target button.
- In the top-left corner of the Script Editor, click on the Menu button and select Play/Debug > SetTarget.
A dialog appears listing all the scripts as well as all the functions in the current script.
- In the Files list of the dialog, select the script you want to test.
-
In the Functions list of the dialog, select the function you want to test.
NOTE If you want to test the whole script from the global scope, select the <Nothing> function.
- Click on OK.
- Do one of the following to execute the target function:
- In the Script Editor toolbar, click on the Run button.
- In the top-left corner of the Script Editor, click on the Menu button and select Play/Debug > Run.