Set a Script to Run when a Mimic is First Displayed in Run Mode
You can use the Mimic_ Load function to set a script to run when the Mimic that contains the script is displayed in Run Mode. This means that the script will run when a User accesses the Mimic (the script does not have to be triggered by any other form of user interaction).
If you are using a script that requires parameters that are specified as part of a hyperlink, you have to use the Mimic_Navigate function instead of the Mimic_Load function. This is because the Mimic_Load function runs as soon as the Mimic opens (that is, before the parameters from the hyperlink have been read). The Mimic_Navigate function works in exactly the same way as the Mimic_Load function except that it runs at a later stage, and so it allows parameters to be read from hyperlinks.
To set a script to run automatically when a Mimic is first displayed in Run mode, simply include a Mimic_Load or Mimic_Navigate function in your script. The Mimic_Load function instructs the system to run the script when the Mimic is first displayed in Run Mode. The Mimic_Navigate function has a similar effect, but it allows hyperlink parameters to be used as it runs in a later stage of the Mimic opening sequence.
NOTE: Mimic_Load and Mimic_Navigate functions only run when the Mimic is displayed in Run Mode.
The syntax for using the Mimic_Load function is:
Sub Mimic_Load()
End Sub
Mimic_Load is designed to be used with top-level Mimics only, and should not be used in scripts on embedded Mimics. This is because it is difficult to predict when the script will run:
- With embedded Mimics that are configured to be shared, Mimic_Load runs whenever the embedded Mimic is loaded into the Mimic cache. When a host Mimic (a Mimic that contains an embedded Mimic) is displayed, ClearSCADA checks whether the embedded Mimic is stored in the Mimic cache:
- If the embedded Mimic is not in the Mimic cache, ClearSCADA will load the embedded Mimic in to the cache and run its script. By loading the embedded Mimic into the Mimic cache, ClearSCADA reduces the overall load of the Mimic, which means the Mimic requires less system resources.
- If the embedded Mimic is already in the Mimic cache, the cached version will be referenced and its script will not run (as it is already in the Mimic cache). The Mimic places less demand on system resources (as a local reference to the cached embedded Mimic is used). As a result, the script does not run.
- With embedded Mimics that are not shared, Mimic_Load runs whenever a non-shared instance of that embedded Mimic is initialized. For example, if a Mimic named ‘Control Room’ contains three embedded versions of a ‘Valve’ Mimic, the script on the ‘Valve’ Mimic will run three times - when each of the embedded versions are initialized.
For the Mimic_Navigate function, a similar syntax is required:
Sub Mimic_Navigate( )
End Sub
As Mimic_Navigate is designed to run when users navigate from top-level Mimic to another, it is unsuitable for use on embedded Mimics (Mimic_Navigate will not run on embedded Mimics).
NOTE: The Mimic_Load and Mimic_Navigate functions have no parameters.