ClearSCADA

It is possible to add script to a mimic that resides outside the bounds of any named function. This code will be run on load of the mimic, irrespective of whether the mimic is in design or run mode.

In some cases, this "feature" has been used as a mechanism to redirect from one page to another by adding the line Mimic.Navigate "xyz".

If you create the redirect this way, then the mimic on which the redirect is configured is now effectively no longer editable. You can never open the mimic again to make any changes. As soon as you try to open it, it is immediately redirected to the other page.

The best way to approach this is to use the built-in Mimic_Load functions. This function is run when the mimic loads, but only if it is in run mode. If you right click on the mimic and open it in design mode, then you will be able to open it and modify the script as required.

It is recommended that global code (code outside the named functions) is only used for things such as variable initialisation etc, and NEVER for mimic redirects using hyperlinks. An example function is shown below...

 sub Mimic_Load()
   Mimic.Navigate "xyz"
 end sub
  1. Apr 15, 2010

    Adam Woodland says:

    Isn't Mimic_Navigate the preferred way rather than Mimic_Load due to some reason...

    Isn't Mimic_Navigate the preferred way rather than Mimic_Load due to some reason I can't remember... perhaps something to do with embedded mimics

    1. Apr 15, 2010

      Stefan Schlatter says:

      I found the following in the online help article "Set a Script to Run when a Mim...

      I found the following in the online help article "Set a Script to Run when a Mimic is First Displayed in Run Mode". Perhaps it is what you are referring to.

      If you are using a script that requires parameters that are specified as part of a hyperlink, you must 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 i.e. 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.