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.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
Tools
menu, choose
Scripting
and then choose
Rescan Script Menu Folder
to update the menu.
234
|
CHAPTER 14
Summary of Contents for Pro 10
Page 1: ...Pro 10 Sound Forge User Manual ...
Page 2: ......
Page 26: ...20 CHAPTER 1 ...
Page 60: ...54 CHAPTER 2 ...
Page 152: ...146 CHAPTER 8 ...
Page 166: ...160 CHAPTER 9 ...
Page 176: ...170 CHAPTER 10 ...
Page 200: ...194 CHAPTER 11 ...
Page 220: ...214 CHAPTER 12 ...
Page 236: ...230 CHAPTER 13 ...
Page 266: ...260 CHAPTER 16 ...
Page 278: ...272 CHAPTER 17 ...
Page 312: ...306 CHAPTER 20 ...
Page 346: ...340 APPENDIX C ...
Page 366: ...360 APPENDIX E ...