Returns dynamically created IDispatch interface of the running script for
the specified language.
Through this property global methods of the currently running script can be called.
Through the property script looks just like a component with methods corresponfding to the
global functions/subroutines defined in the script and properties
corresponding to the global variables. If the script language supports
special property definition syntax (such as VBScript but not JScript)
these properties will be also visible.
Sample:
// Create the component
var scph = new ActiveXObject("newObjects.Scphost.ScpAggregate");
// Add scripting host WScript object as namespace to the ScriptManager2
// with name "world"
scph.Add("world",WScript);
// Load VBScript engine
scph.AddEngine("VBSCRIPT");
// Define the VBScript code
var str = "Sub MyMethod(param)\n";
str += " world.Echo \"Parameter is:\" & param\n";
str += "End Sub";
// Add the code
scph.AddText("VBSCript",str);
// Run the script
scph.Run();
// Call the subroutine
scph.script("VBScript").MyMethod("Hello World !");
The output will be:
Parameter is:Hello World!
Take care for the parameters passed to the script methods. For example in JScript exact
match is not required but in other languages like VBScript parameters must match the
function/sub declaration.