Scripting question

PaulieT wrote on 7/24/2025, 8:11 PM

Hi Everyone,

I'm writing a Sound Forge script and using a sample script as a basis. I'm using Sound Forge 10 in Windows 11, but the same thing appears in Sound Forge 17.

In the sample script there is a command "DPF" which obviously prints to the Sound Forge window.
DPF ("Template: '{0}'", vPreset);

There is also another command "GETARG" which obviously gets user input.
string szDir   = GETARG("dir", "");

I cannot find either command in the Sound Forge API Help (chm) file and neither are C#, or C commands.

Any suggestions as to what I am missing?

Thanks for your help,


 

 

Comments

SP. wrote on 7/25/2025, 6:08 AM

@PaulieT Usually the DPF and GETARG functions in the examples are placed at the bottom of the script. These are just there so you don't need to type ForgeApp.OutputText(String.Format()) in case of DPF() or perform length checks or null checks for arguments.
 

public static void DPF(string sz) {
  ForgeApp.OutputText(sz);
}


public static void DPF(string fmt, object o) {
ForgeApp.OutputText(String.Format(fmt, o));
}


public static void DPF(string fmt, object o, object o2) {
ForgeApp.OutputText(String.Format(fmt, o, o2));
}


public static void DPF(string fmt, object o, object o2, object o3) {
ForgeApp.OutputText(String.Format(fmt, o, o2, o3));
}


public static string GETARG(string k, string d) {
  string val = Script.Args.ValueOf(k);

  if (val == null || val.Length == 0)
    val = d;

  return val;
}


public static int GETARG(string k, int d) {

  string s = Script.Args.ValueOf(k);

  if (s == null || s.Length == 0)
    return d;
  else
    return Script.Args.AsInt(k);
}


public static bool GETARG(string k, bool d) {

  string s = Script.Args.ValueOf(k);

  if (s == null || s.Length == 0)
    return d;
  else
    return Script.Args.AsBool(k);
}


public static double GETARG(string k, double d) {

  string s = Script.Args.ValueOf(k);

  if (s == null || s.Length == 0)
    return d;
  else
    try {
      d = double.Parse(s);
    } catch {

    }

  return d;
}

They are basically there to save you from typing more code, but you don't need to use them.

PaulieT wrote on 7/25/2025, 3:54 PM

Thanks SP,

That helps a lot. However, where is ForgeApp.OutputText and where are these methods defined?

Thanks,
Paul

 

SP. wrote on 7/26/2025, 5:42 AM

@PaulieT For ForgeApp look under IScriptableApp