WindowClose
(Engine-Level Function)
Description: | Returns true if an attempt is made to close the window. |
Returns: | Boolean |
Usage: | Steady State only. |
Function Groups: | Window |
Related to: | VStatus | Window | WindowOptions |
Format: | WindowClose(Object) |
Parameters: |
Object |
Required. Any expression that returns the object value of any module instance drawn in the window. |
Comments: |
Only one WindowClose() should run with a window at a given time.
If this function is active when an attempt to close a window is made, the window will not close, and the module(s) in that window will not stop. It is up to the calling module to close the window and stop the module(s) by switching to another state. Notes on closing a window: When WindowClose behavior is active, the typical way to close a window is by making one of the following happen:
Calling Slay on the root object of the window does not work. (For example, calling Slay(Self) from the window's root object.) The root object of the window is called in steady-state, from the Window function's 7th parameter. Slaying an object that has been called in steady-state does nothing because it does not affect the calling object: the calling object would still be in it's same state with that same Window() call running, and therefore the called Window module cannot be permitted to stop. If the calling object is launched, then a common approach is to slay that calling object. For example, Slay(Caller(Self)) rather than Slay(Self) may work, depending on how the object was launched. |
It is possible for a WindowClose statement to be associated with a window, but to not yet be running when the attempt to close the window is made. If this happens the slay of the module running in the window will continue up the module tree until a running WindowClose is found, or the top of the tree is reached. This behavior may be undesirable. The scenario can be avoided by setting bit 19 of the Style option in the Window statement. Doing so will warn VTScada that a WindowClose statement will be associated with this window.
Example:
If WindowClose(Self()) CloseEverything;
This statement causes a state change to CloseEverything if the user attempts to close the current window. It is then up to code in CloseEverything to perform any necessary clean-up tasks and close the window.