Description: This statement stops a launched module, and possibly any parent modules.
Returns: Nothing
Usage: Script
Format: Slay([Object, KillParents])
Parameters: Object { Object value } { optional } { default: self() }
An optional parameter which is any object expression for the launched module. The default value of Object is Self().
KillParents { Boolean } { optional } { default: 0 }
An optional logical expression for the action to take. If true, Slay will attempt to stop parents as well; if any parent libraries are not launched, the Slay statement won't search for further modules instances. The default value for KillParents is 0.
Comments: When this statement is encountered in a script, the module is immediately stopped; Slay and Return are the only statements that will cause a script to terminate mid-way through its execution. Others like ForceState will not.
Slay() is the same as Slay(Self(), 0).
Example:
If ZButton(20, 50, 120, 70, "Motor On/Off", 1);
[
IfElse(!motorOn, Execute(
motorOn = 1,
motorPtr = RunMotor() { Module launched implicitly }),
{ else } Execute(
motorOn = 0,
Slay(motorPtr, 0)));
]
When the button is selected, the statement in the script will check if the motor is running or not, and if it isn't, will launch the module that starts it; notice that the module is launched implicitly because it is called from inside of a script. If that module is already running it will stopped by the Slay .
See Also: