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.
Sample:
// Create the component
var scph = new ActiveXObject("newObjects.Scphost.ScpMan2");
// Add scripting host WScript object as namespace to the ScriptManager2
// with name "world"
scph.Add("world",WScript);
// Load VBScript engine
scph.LoadEngine("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(str);
// Run the script
scph.Run();
// Call the subroutine
scph.script.MyMethod("Hello World !");
The output will be:
Parameter is:Hello World!
Global variables of the script can be accessed as a properties.
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.