Sony SF-10000 Computer Accessories User Manual


 
Script arguments
A script can accept arguments to dynamically change the behavior of a script. Arguments allow you to develop a single script that
performs multiple functions controlled by the arguments sent to the script.
Each argument is a key/value pair. The key is a string that identifies the argument’s value. Multiple arguments are delimited by an
ampersand (&).
key1=value1&key2=value2&key3=value3…
When you supply arguments to a script, the following static functions can be used to extract and format the parameters:
public static string GETARG(string key, string str) { string val = Script.Args.ValueOf(key); if (val == null) val =
str; return val; }
public static int GETARG(string key, int ii) { return Script.Args.AsInt(key,ii); }
public static Int64 GETARG(string key, Int64 cc) { return Script.Args.AsInt64(key,cc); }
public static bool GETARG(string key, bool ff) { return Script.Args.AsBool(key,ff); }
public static double GETARG(string key, double dd) { return Script.Args.AsDouble(key,dd); }
The first argument to the GETARG functions specifies a key name that is used to identify the argument to be extracted. The second
argument in the GETARG function is a default value to be returned if the function cannot find the key name. The second argument also
determines which overloaded function the script will use and how the value will be formatted.
For example, consider a script that accepts three input parameters. The syntax for the arguments is as follows:
in=C:\Test\input.dls&out=C:\Test\output.dls&repeat=2
The script to handle the parameters would look as follows:
using System;
using System.IO;
using System.Collections;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Drawing;
using SoundForge;
using SoundForge.BatchConverter;
public class EntryPoint {
public string Begin(IScriptableApp app) {
string inFile = GETARG("in", "");
string outFile = GETARG("out", "" );
int count = GETARG("repeat", 0 );
Adding scripts to the Scripting menu
When you start the program, Sound Forge software looks at the Script Menu folder in the Sound Forge program folder to determine
which scripts appear in the Scripting submenu. This folder is C:\Program Files\Sony\Sound Forge Pro 10.0\Script Menu by default.
1.
To change the contents of the submenu, add or delete scripts in the Script Menu folder.
Tip:
To prevent duplication of script files, you can use shortcuts in the Script Menu folder.
2.
From the Tool s menu, choose Scripting and then choose Rescan Script Menu Folder to update the menu.
234
| CHAPTER 14