Comments

jetdv wrote on 9/18/2003, 8:46 PM
My understanding is that calling another script does not work.
Cendron wrote on 9/21/2003, 11:50 AM
Oh ? That's too bad !

There are still the RunScriptFile method of the ScriptHost Class. I tried it. It works, but I got then repetitive error messages saying: "An error occurred while processing the undo buffer. You should save your work immediately usig a new project filename and restart Vegas. The reason for the error could not be determined."
Closing and reopening Vegas solve the problem, but it's not very practical!

I tried also this:

import SonicFoundry.Vegas;
var WshShell = new ActiveXObject("WScript.Shell");
var oExec = WshShell.Exec(<script to execute>);

With same results: it works, but Vegas don't work after the running.
Any idea?

2G wrote on 9/21/2003, 7:15 PM
Thanks for the info. Since that doesn't seem to be the best approach, is there a way to call a script from a command line and pass parameters?

I guess I shouldn't be picky. I'm thrilled with the scripting capability. I just would like to push the envelope just a little more.

Thanks again.

2G
jetdv wrote on 9/22/2003, 8:56 AM
Yes, you can start Vegas with a script as a command line parameter and Vegas will automatically run that script upon starting.

If you are trying to start the script by passing parameters to that script, save the parameters in an INI or XML file and have the script read the parameters after it starts.
SonyPJM wrote on 9/22/2003, 9:27 AM

The way to run a script from the command line is like so:

"C:\Program Files\Sonic Foundry\Vegas 4.0\vegas40.exe" -SCRIPT:"C:\path\to\YourScript.js"

You can also send a running instance of Vegas a WM_COPYDATA message
with the name of a script to run. Here is some sample code:

http://www.ayizwe.net/VegasScripts/RemoteControl.zip
2G wrote on 9/24/2003, 11:00 PM
The problem with all of these options is that you can't pass a parameter in. I have a really nice script that I use with a bunch of projects. But I have to customize it in a few places for each project. So I either have to continually edit and customize each time I run it, or I have to keep a bunch of copies around which is a maintenance nightmare as the script evolves. One response suggested reading parms from an INI file. But then I still have to edit the script to change the INI file name.

I'm a seasoned Java and C++programmer. In those realms, I would simply create an object out of the body of code and use the object in very short scripts that pass the needed parameters.

Am I going about this wrong? I don't know enough about JScript to figure out if I can objectize my code and call it. Am I basically stuck with what I have, or are there alternatives?

I guess my real question is whether there is any way to pass a parm to a script.

Thanks again.

2G
jetdv wrote on 9/25/2003, 8:15 AM
Why not just pop up a GUI screen and ASK for the individual pieces of information?
SonyPJM wrote on 9/25/2003, 10:07 AM

It does sound like a GUI with parameter settings is the way to go.
This might eliminate the need to call a script from within a script.
Perhaps list of presets might help you quickly choose a parameter
set. You can use all the classes in the System.Windows.Forms namespace
to create the GUI. You can maybe even add the ability to save preset
data to a file. You can also use the registry and XML files for
persistence.

There is a global variable called ScriptFile that tells you the full
path of the currently running script. This can help you save data in a
logical place. More details here:

http://www.ayizwe.net/VegasScripts/FAQ.html#1.7


The .NET scripting framework is structured differently from something
like a command-line app and there is no traditional (argc/argv) way to
pass parameters to a script. However, I am open to ideas for the next
version of Vegas... suggestions are welcome.

One approach I've considered is to make the XmlDocument object that is
created from the script configuration file available to the script
itself in a global variable... call it something like ScriptConfigDoc.
The script configuration file is parsed each time the script is run
anyway so there is minimal cost to making it available. Then, if the
script wants to persist some data in its config file, it can
add/remove/alter nodes in ScriptConfigDoc and then call a simple
method like:

Vegas.SaveScriptConfig(ScriptConfigDoc);
2G wrote on 10/23/2003, 6:39 PM
I'm all for anything to assist automation, and anything that will help me write code once and reuse.

I could do a GUI, but the parameters are typically input and output directory paths, which are not short. I don't want to have to enter long path names every time I run the script.

Maybe I'm asking the wrong question. What I would really like to do is create my own library with a few reusable classes. Then I can write tiny little scripts that basically do nothing but call my classes. I know C++ and Java extensively, but limited experience with JScript. I've looked at the JScript site to get more info and a little tutorial. But haven't really found anything useful. I know this is out of the realm of the Vegas scripting forum. But 1) how hard is it to create my own JScript packages (does it require add'l build tools)? And 2) where could I get a good tutorial on how to do it.

Thanks.

2G
SonyPJM wrote on 11/5/2003, 11:50 AM
You can achieve your goal by writing a .net assembly that contains all
of your helper classes and methods. There's a FAQ on using custom
assemblies here.



You can create assemblies in JScript, C#, or whatever.
2G wrote on 12/13/2003, 9:11 AM
Thanks so much for the info. That's exactly what I'm looking for.

But I need one more piece of information. I'm a very experienced java J2EE programmer, but no experience in .net. Can you give me a couple of pointers or web sites on how to create .net assemblies from jscript files? I just don't know the .net tool set. All the .net basics sites I found on google offer 5 day courses. All I want is an idea of what kind of compiler/etc I need to invoke to create the .dll.

Any pointers would be very helpful.

Thanks again.

2G