newObjects-logo.gif (1024 bytes) ScriptManager2 reference
script property

read only

Returns dynamically created IDispatch interface of the running script

variable = object.script

variable object Running script as dispatch interface
object ScriptManager2 Previously created ScriptManager2 object


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.


// Create the component
var scph = new ActiveXObject("newObjects.Scphost.ScpMan2");
// Add scripting host WScript object as namespace to the ScriptManager2
// with name "world"
// Load VBScript engine

// Define the VBScript code 
var str = "Sub MyMethod(param)\n";
str    += "        world.Echo \"Parameter is:\" & param\n";
str    += "End Sub";
// Add the code
// Run the script
// 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.

See also:

C++ Helper SCPHOSTCLNT::GetScriptDispatch method

newObjects Copyright newObjects 2001-2005