I ran a script written on SFv10 on SFv8 and received this error message:
System.ApplicationException: 1 compiler errors.
at SoundForge.CodeDomScriptManager.Compile(String szFile, String szSourceText)
at SoundForge.ScriptHost.RunScript(String szFile, String szSourceText, EngineType eType, Boolean fCompileOnly, Boolean fDebug)
Here's the script:
using System;
using System.IO;
using System.Windows.Forms;
using SoundForge;
using System.Collections;
using System.Collections.Generic;
public class EntryPoint
{
public void Begin(IScriptableApp app)
{
// maxLength is the length of one CD in samples.
long maxLength;
// stepSize is the length of one CD track in seconds.
long stepSize;
// trackLength is the length of one CD track in samples.
long trackLength;
ISfDataWnd wnd = app.ActiveWindow;
if (null == wnd)
{
MessageBox.Show("Open a file before running this script");
return;
}
ISfFileHost file = app.CurrentFile;
trackLength = 300;
maxLength = (74 * 60) * file.SampleRate;
stepSize = trackLength * file.SampleRate;
if (file.Length < stepSize)
{
MessageBox.Show("Your file is shorter than one track in length. No regions have been created.");
return;
}
if (file.Length > maxLength)
{
MessageBox.Show("Your file is longer than 74 minutes in length, which is the limit of one CD. You will have to split the file across multiple CDs. No regions have been created.");
return;
}
//Delete any existing markers and regions.
file.Markers.Clear();
//Create undo wrapper
string szUndo = String.Format("Create Markers for CD");
int idUndo = file.BeginUndo(szUndo);
long spacer = 0;
int offset = 1;
int inc = 1;
//Find out how many markers we need
long markNum = file.Length / stepSize;
//Add markers to all but the last segment
for (int x = 0; x < (markNum - offset); x++)
{
file.Markers.AddRegion(spacer, stepSize, "Track_" + (x+1));
spacer += stepSize;
inc++;
}
//Deals with the last segment
long leftOver = file.Length - spacer;
file.Markers.AddRegion(spacer, leftOver, "Track_" + inc);
//Close undo wrapper
file.EndUndo(idUndo, false);
Do("TrackList.CreateCDTracksFromRegions");
MessageBox.Show("This audio file has been converted to CD tracks. To write the file to a CD, click Tools->Burn Disc-At-Once Audio CD and follow the directions.");
}
public void FromSoundForge(IScriptableApp app)
{
ForgeApp = app; //execution begins here
app.SetStatusText(String.Format("Script '{0}' is running.", Script.Name));
Begin(app);
app.SetStatusText(String.Format("Script '{0}' is done.", Script.Name));
}
public static void Do(string cmd) { ForgeApp.DoMenuAndWait(cmd,false); }
public static void Do(string cmd, bool fUseLastPreset) { ForgeApp.DoMenuAndWait(cmd,fUseLastPreset); }
public static IScriptableApp ForgeApp = null;
public static void DPF(string sz) { ForgeApp.OutputText(sz); }
public static void DPF(string fmt, params object[] args) { ForgeApp.OutputText(String.Format(fmt, args)); }
} //EntryPoint
Any help would be appreciated.