newObjects-logo.gif (1024 bytes) ScriptAggregate reference
Run method

Runs the script.

variable = object.Run([order])

variable boolean true if the operation was successful and false if not
object ScriptAggregate Previously created ScriptAggregate object
order number order of execution of the scripts - see remarks. Default 0

Remarks:

After loading the script code (see AddText and AddTextEx methods) Run method can be called to run the script.

Running script means executing of the all global script code and parsing definitions of the functions/subs in the text. For many applications this is enough i.e. loading some script and executing it. Thus script text is some kind of sequential commands (possibly helper/library functions) and the script is executed once in order to do its work.

Most advanced usage of the Active Scripts is to use Run method only just a preparation for later usage. After the method returns (with success status) global functions/subs defined in the script can be called randomly by the hosting application (global data variables can be accessed too). In this case script acts as a flexible component that provides services to the hosting application. Script is not loaded and not reinitialized between operations and it works a times faster then in the case of executing the entire script for every action.

Order parameter. Order in which the scripts written in different languages  are executed could be important. For example if code in one of the scripts refers to routines and variables in another language then the referee must be started first. To meet these needs the order parameter gives you ability to control the order of the startup sequence:

0 - will start the scripts in the same order the script engines are added. E.g. if you have:
host.AddEngine("VBScript")
host.AddEngine("JScript")
' Add some code
host.Run 0

The code written in VBScript will be started first then the JScript code. And if the JScript code calls some functions from the VBScript code everything will be ok, but if VBScript code calls functions of the JScript code error will occur.

-1 - Negative order - the last added language will be started first and so forth to the first one.

See also:

C++ Helper SCPHOSTCLNT::Run method
script property

newObjects Copyright newObjects 2001-2005