Add and remove curve to/from trend dynamically

<< Click to Display Table of Contents >>

Navigation:  Examples > Trends >

Add and remove curve to/from trend dynamically

Previous pageReturn to chapter overview

If we want to add and remove curves to/from trend dynamically you also have to use scripts.

First let's create 2 tags based on Tag1 from previous example. Name them Tag2 and Tag3.

Second let's create 2 tags - Add and Remove. When value of these tags are changed from FALSE to TRUE we add or remove curve.

Third let's create tag - Number. This tag will contain information about which tag we want to add or remove. All our tags looks like below:

addremovecurvetags

Let's bind Add and Remove tags to the Control property of the Button:

addcontrolbuttonremovebutton

Let's bind tag Number to the ComboBox object and fill up ranges collection by tag's names:

comboboxrangecollection

Now let's create 2 scripts for adding and removing curves:

addcurveremovecurve

Below text of the script to add curve. We use addcurve function from Trend's curve library:

addcurvetext

Below text of the script to remove curve:

removecurvetext

We need to bind these scripts to the tags- Add and Remove:

addtagscriptremovetagscript

Now when we click buttons Add and Remove we call correspondent scripts.

Let's Run simulation to check your settings:

trendaddremovecurve

You can download this project here.