Archive

Archive for August, 2008

Gino 0.2

29 August 2008 Ivo Leave a comment

Gino 0.2 has hit the SVN. (What’s Gino? http://www.assembla.com/wiki/show/etools/Gino)
It is delivered with a nice setup.py. With the help of py2exe, it is possible to make it a windows binary, easily portable.
The next steps? fix some(many) bugs, and prepare a Inno setup to deploy it.

If you want to try it, you can get the sources from assembla.com (http://svn2.assembla.com/svn/etools). (What are the etools? http://www.assembla.com/wiki/show/etools/Gino).

This project has been written with eclipse and pydev extensions. It isn’t clear which kind of license it will use, yet.

javascript code to use WScript parameters

27 August 2008 Ivo 3 comments

The following code makes use of the WScript.Arguments.Named and Unnamed properties to retrieve and use the WshNamed and WshUnnamed objects.

You can find something on MSDN about this topic, but this is a useful and till-now-missing example (IMHO).

For example, call it with “cscript /Nologo libparam.js /debug bla=bla key=value /verbose”.

var argsNamed = WScript.Arguments.Named;
var argsUnnamed = WScript.Arguments.Unnamed;

function Parameters (argumentsNamed, argumentsUnnamed, splitCharacter) {
    this.splitChar = splitCharacter;
	this.named = argumentsNamed;
    this.unnamed = argumentsUnnamed;
	this.unnamedOptions = new Array()

	this.decomposeUnnamedOptions = function ()
	{
		if (typeof(this.unnamed) == 'undefined')
			return
		//WScript.Echo("this.unnamed.length: " + this.unnamed.length);
		for (var j = 0; j  2)
				continue;
			if(typeof(parts[1]) == 'undefined')
				this.unnamedOptions[parts[0]] = 'undefined';
			this.unnamedOptions[parts[0]] = parts[1];
		}
	}

	this.debug = function () {
		WScript.Echo("Parameters class inited.");
		WScript.Echo("There are " + this.named.length + " named arguments.");
		WScript.Echo("There are " + this.unnamed.length + " unnamed arguments.");
		WScript.Echo("The split character is '" + this.splitChar + "'");
		WScript.Echo("The named args are "+this.named.length+" :");
		for (var j in this.named) {
			WScript.Echo("named(" + j+"):"+this.named.Item(j));
		}
		WScript.Echo("The unnamed args are "+this.unnamed.length+" :");
		for (var j = 0; j < this.unnamed.length; j = j + 1) {
			WScript.Echo("unnamed(" + j+"):"+this.unnamed.Item(j));
		}
	}

}

params = new Parameters(argsNamed, argsUnnamed, "=");

params.decomposeUnnamedOptions();

if (params.named.Exists("debug"))
	params.debug();

if (params.named.Exists("verbose"))
	WScript.Echo("---begin processing unnamed args");

if (!params.named.Exists("noresults")) {
	for (var i in params.unnamedOptions) {
		WScript.Echo('key is: ' + i + ', value is: ' + params.unnamedOptions[i]);
	}
}

if (params.named.Exists("verbose"))
	WScript.Echo("---end processing unnamed args");