Change values of 2 tags by one click

<< Click to Display Table of Contents >>

Navigation:  Examples > Change tag's value >

Change values of 2 tags by one click

Previous pageReturn to chapter overviewNext page

In this example, we'll show you how to change the values of two tags with one click. Suppose we have two containers with liquid that needs to be heated to either 50°C or 70°C. By pressing one button we will set the temperature in both containers - 50°C, and by pressing the other - 70°C.

 

Let's create two tags - Tag2 and Tag3. We will change the values of these tags simultaneously by pressing the buttons. These buttons will toggle the intermediate tags - write50 and write70.

 

1. Let's create Tags:

 

tagswrite2tags

 

2. Create buttons and bind write50 and write70 tags to two buttons:

 

twobuttons

controlbutton2write

controlbutton0write

 

3. Now let's create 2 scripts that will be called when the values of these two tags are switched from FALSE to TRUE:

 

scripts2tags

script10value

script0value

 

After you have recorded the script, be sure to launch it by clicking the button on the toolbar: runsimulation

 

4. And let's bind these 2 scripts to tags - write50 and write70:

 

tagpropertywrite0

tagpropertywrite10

 

Now when tags write50 and write70 switch from FALSE to TRUE, the corresponding script is called.

 

5. Run simulation to check the settings:

 

write2tags

 

You can download this project here.