Subject:RE: Learning Soundforge scripting
Posted by: stikyy
Date:7/19/2005 7:38:10 PM
Here is another sample. This script works fine in soundforge, but as soon as i take it to VS.NET 2003 is doesn't run (compiled as a class library). Imports System Imports System.IO Imports System.Windows.Forms Imports SoundForge Imports System.Drawing Public Class EntryPoint Public Function Begin(app as IScriptableApp) 'begin here Dim myform As Form myform = New Form Dim rc As SfRectangle = app.WindowRect myform.Location = New Point(rc.left + (rc.right - rc.left - myform.Width) / 2, rc.bottom - myform.Height - (rc.bottom - rc.top - myform.Height) * 1 / 4) myform.ShowDialog() End Function Function FromSoundForge(app as IScriptableApp) ForgeApp = app app.SetStatusText(String.Format("Script '{0}' is running.", Script.Name)) Begin(app) app.SetStatusText(String.Format("Script '{0}' is done.", Script.Name)) End Function Public ForgeApp as IScriptableApp Public Function DPF(sz) ForgeApp.OutputText(sz) End Function Public Function DPF(sz,o) ForgeApp.OutputText(System.String.Format(sz,o)) End Function Public Function DPF(sz,o,o2) ForgeApp.OutputText(System.String.Format(sz,o,o2)) End Function Public Function DPF(sz,o,o2,o3) ForgeApp.OutputText(System.String.Format(sz,o,o2,o3)) End Function End Class 'EntryPoint Message last edited on7/22/2005 1:46:11 AM bystikyy. |
Subject:RE: Learning Soundforge scripting
Reply by: ghova
Date:7/20/2005 7:01:19 AM
I've had similar issues. I'm not as experienced with programming as you, so I probably can't tell you anything you don't already know. However, since the forum moderators haven't posted in a few weeks, I just wanted to chime in. Correct me if I'm wrong, but the problem seems to center around passing the code to Sound Forge. The only way I've seen scripts get triggered are by either manually starting the script, or by invoking Sound Forge through a command line, with the script path as an argument (there's a thread about this in the forum). If a script could be triggered in any other way, I'd love to know, as it would mean I could code in a VB editor instead of the bare-bones Sound Forge Script editor. ~Gil |
Subject:RE: Learning Soundforge scripting
Reply by: jetdv
Date:7/20/2005 7:09:04 AM
First of all, assuming you are going to C# instead of JScript, the "imports" must be changed to "using". Here's the guts of one I've done in C# in VS.Net 2003 compiled to a DLL: using System; using System.Drawing; using System.Collections; using System.IO; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Reflection; using Microsoft.Win32; using SoundForge; public class EntryPoint { private static BatchConvert.BatchConvertForm form; private static IScriptableApp app; public void FromSoundForge(IScriptableApp app) { EntryPoint.app = app; // your code begins here. app.SetStatusText("Script Started"); app.SetStatusText("Script Complete"); } } namespace WhateverYouWant { /// <summary> /// Summary description for Form1. /// </summary> public class YOURForm : System.Windows.Forms.Form { private SoundForge.IScriptableApp forge; /// All form stuff deleted private System.ComponentModel.Container components = null; public YOURForm(SoundForge.IScriptableApp app) { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // forge = app; // Do other stuff here } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code //rest of the form stuff removed } |
Subject:RE: Learning Soundforge scripting
Reply by: stikyy
Date:7/22/2005 1:37:46 AM
I was trying to work with VB.NET thats what i am most familiar with. I am trying to display a form (see my code from previous post). This code works fine in the Sound Forge script window (without the System.data import) but it doesn't work (the same exact script) if you compile into dll and try to run it. Is there a problem with running VB Script? Do i have to use C# Message last edited on7/22/2005 1:46:59 AM bystikyy. |
Subject:RE: Learning Soundforge scripting
Reply by: stikyy
Date:7/22/2005 2:14:17 AM
OK, for anyone interested i figured out the problem. In VB.net when you create a project by default the root namespace in the project properties gets defaulted to the project name. This needs to be blank or otherwise it doesn't work... Go to project properties, Common properties -> General. The root namespace box should be blank. If you are using c# this property window looks different. |