Opening and running a script

You can open and run a script that has already been developed.

Warning: Scripts can pose a security risk to your computer. A script has the power to delete files, read files, write files, execute programs, access the Internet, access files on your network, and so on. Always examine the contents of a script before running it. If you don't understand the script, do not run it unless it comes from a trusted source. In general, take the same precautions you would take for any program you download from the Internet or receive in an e-mail attachment.

Running a script from the Script Editor window

1.Click in the data window where you want to apply the script to establish focus.

2.From the View menu, choose Script Editor to display the Script Editor window if it isn’t already displayed.

3.Click the Open button () in the Script Editor toolbar. The Open Script window is displayed.

4.Select the script file (.vb, .js, .cs, or .dll) that you want to run. The script data is displayed in the top portion of the Script Editor window.

5.If you need to pass an argument to the script, type it in the Script Args box. Arguments are specified as follows:

ArgName=ArgValue&ArgName2=ArgValue2. . .

For example, a script that uses an argument to indicate where files should be saved could use the following argument to save files to a ScriptOutput folder on your D:\ drive: dir=d:\ScriptOutput.

If your script can create a log file to record the results of a scripting operation, you could append that argument as follows: dir=d:\ScriptOutput&logFileName=myLog.txt. In this example, the ampersand (&) separates the two arguments. The first argument sets the save folder, and the second argument sets the file name for the log file.

For more information, see Script arguments on page 234.

6.Click the Run Script button ().

Running a script from the Scripting menu

1.Click in the data window where you want to apply the script to establish focus.

2.From the Tools menu, choose Scripting.

3.Choose a script from the submenu or choose Run Script from the submenu to browse to the script file (.vb, .js, .cs, or .dll) that you want to run.

Running a script from the command line

In addition to running scripts from the Script Editor and the Scripting menu, you can run scripts directly from the command line using the following commands.

SCRIPT

Starts Sound Forge and runs the specified script.

Example: "C:\Program Files\Sony\Sound Forge Pro 10.0\Forge100.exe" -SCRIPT:"C:\Scripts\MyScript.cs"

SCRIPTARGS

Starts Sound Forge and passes the specified arguments to a script.

Example: "C:\Program Files\Sony\Sound Forge Pro 10.0\Forge100.exe" - SCRIPTARGS:"in\C:\Test\input.dls&out=C:\Test\output.dls&repeat=2" -SCRIPT:"C:\Scripts\MyScript.cs"

EXIT

Exits Sound Forge after running the specified script.

Example: "C:\Program Files\Sony\Sound Forge Pro 10.0\Forge100.exe" -SCRIPT:"C:\Scripts\MyScript.cs"-EXIT

USING SCRIPTING 233