Call us! 512-349-0334 or (877) INDUSOFT

Modifying Linked Symbols to Add a Challenge Screen or Message Box in InduSoft Web Studio

InduSoft Web Studio users sometimes ask how to modify a linked symbol in order to add a popup dialog that challenges the current operation or state, such as turning a pump on or off. Most commonly, a developer or engineer will simply create the automation outside of the control requiring another screen and an external script in order to add the the functionality to the object. This is not a very good solution, especially when there is a need to use this symbol in a number of other projects. The reason is that the solution does not move with the copied linked symbol to the new project.  All the added screen(s) and external automation must also be added to each new project, and object troubleshooting later on can become troublesome, among other problems.

The following discussion however, will describe a procedure to create a single linked symbol with contained challenge screens that can be modified easily within an existing object, or the newly modified linked symbol can be added to a new project simply by copying the new linked symbol file to the new project’s \Symbol folder.

The key to this functionality is to use the VB function, “MsgBox()”. MsgBox() has a variety of states and features that can be used beyond the scope of this discussion. More information about advanced MsgBox() functionality can be found on the MSDN Website.

For this example, the Library SymbolPump01” will be saved and modified to demonstrate the Challenge Popup Functionality.

First, place a copy of Pump01 on a screen, then right-click and select “Edit Linked Symbol” from the menu. Next, go to the InduSoft Web Studio Button Menu (Top Left-Hand corner of the Development Environment)  and select “Save As” and save the linked symbol in the project’s \Symbols folder. The modified symbol will be available for use in the project simply by opening the “Project Symbols” in the Project Tree (e.g., pump01-mod1.sym).

Project Symbols

Next, select the object in the Linked Symbol Editor and right-click, then select Ungroup. Click off the object, then click and drag the green pump off the red one.

New Saved Symbol

You can now see how this symbol operates, by double-clicking on one of the pumps and looking at the Visibility Animation. The object is made visible using the custom property #TagState: , which is normally defined during Runtime using the System Tag $BlinkSlow. When the custom property is set to “0”, the red pump is visible, and when it is set to “1”, the green pump is visible. During Runtime, $BlinkSlow toggles from 0 to 1, causing the red and green pumps to alternately become visible.

 RedPumpVisability GreenPumpVisability

For this example, the system tag $BlinkSlow will be removed from the linked symbol for clarity of this discussion, and the custom property #TagState will simply be defined (in the visibility animation), hard-coded as 1 or 0, or tested (in the command animation) during Runtime when it is set by the value of a Boolean project tag.

Add a Command Animation to each of the pump symbols, and in the Red On-Down Command place the following script:

Dim res

res = MsgBox(“Are you sure you want to start the pump?”, vbYesNo + vbExclamation, “Start Pump?”)

If res = vbYes Then $#TagState: = 1

RedPumpCommand

and in the Green On-Down Command place the following script:

Dim res

res = MsgBox(“Are you sure you want to stop the pump?”, vbYesNo + vbExclamation, “Stop Pump?”)

If res = vbYes Then $#TagState: = 0

Note: The quotation marks in the scripts are not “SmartGreenPumpCommand” quotes but are the standard ASCII double-quote character (ASC 34). If you edit or copy and paste the script using MS Word or another word processor for instance, the application may change the (ASC 34) quotes to “Smart quotes” which won’t work in the MsgBox() function.

Put the green pump back on top of the red one and select them both, then right-click and select Group in order to group the parts back into one symbol. Save and Close the Linked Symbol Editor Screen. Save the project screen, then double-click the newly edited linked symbol to open the Properties. In the blank space where $BlinkSlow used to be in the properties of the Symbol Library Pump01 symbol, enter the Boolean Tag that will control Pump Operation (e.g., $PumpRun).

SymbolTagInsertion

Go to Runtime and verify that Challenge Popup Functionality has been added to the new Pump Linked Symbol.

StartChallenge StopChallenge

Comments are closed.