Application Control
Synchronous
No Custom Parameters
Final
Forward informs the Application Runtime Environment to destroy the script instance and route all events destinated for this script instance to the instance defined in the ToGuid.
Once a script is ended with Forward, any non-triggering events (unsolicited or asynchronous) routed to this now-defunct script instance will be forwarded to the script instance specified in the ToGuid parameter. The script instance forwarded to does not receive any notification that it was forwarded to--if this is necessary for an application then one should use SendEvent before the Forward.
Forward unloads the resources associated the script, such as global variables. Every script should always come to an end with either Forward or EndScript; otherwise, script instances will continue to build up which consumes memory resources on the system.
Ending a script instance is important with regards to licensing; the application server licensing scheme is based on the amount of concurrently running scripts. Ending a script instance with Forward releases one license unit.
When a script ends, the InstanceDestruction event is fired with an ErrorCode value of 1. Because this event is fired whenever the script ends for any reason (including the use of Forward), this provides a clean location to implement any clean-up code for the script instance.
While it is conceivable to create a script which acts as a singleton and all other scripts forward to it, this model may not scale well depending on the amount of events being routed to the singleton script. Scripts execute functions sequentially (and therefore events as well), so one script instance would conceivably do a very poor job of keeping up with the number of events associated with a high number of forwarded-from script instances. Ultimately, the ability of a script to process events is based on how much time each function takes and at what rate events are coming into the script.
The other means by which a script instance can end are by EndScript, being unloaded, and by crashing (such as when an unhandled exception occurs in a CustomCode action or a native action).
Forward is an example of a final action, which means no other actions can occur after this action in the function from which it was invoked. In the special case of EndScript or Forward, the only actions in the current script instance that can occur after their usage are those in the InstanceDestruction event handler.
| Parameter Name | .NET Type | Default | Description |
|---|---|---|---|
| ToGuid * | System.String | Must be a valid RoutingGuid of a running script instance. |
No Result Data
No Defined Branch Conditions