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

read only

Returns dynamically created IDispatch interface of the running script for the specified language.

variable = object.script(language)

variable object Running script as dispatch interface
object ScriptAggregate Previously created ScriptAggregate object
language variant Language name or language index (returned by WhereIsDefined method)


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.


// Create the component
var scph = new ActiveXObject("newObjects.Scphost.ScpAggregate");
// 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("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.

See also:

C++ Helper SCPHOSTCLNT::GetScriptDispatch method

newObjects Copyright newObjects 2001-2005