GetValue

Parent Previous Next

GetValue

Function returns the ITag value or null if it is not an ITag.

Syntax:

Object GetValue(string tagName);


Params:

String tagName: a string parameter that contains the tag name.


Return:

Object: value of the tag passed as parameter;


Example: Filtering tags and getting their values using SVTags.


In this example, we will need to create the following scenario:


.     Create 10 tags with their default type as integer:


graphic



.     Create a graphic with 1 button as in the image below:


graphic



.    Now let's configure the button with the following code:



Dictionary<string, List<string>> filters = new Dictionary<string, List<string>>();

List<string> lsF = new List<string>();

lsF.Add("1");

lsF.Add("2");

lsF.Add("3");

lsF.Add("4");

lsF.Add("5");

filters.Add("NewTag", lsF);

List<string> lstreturn = SVTags.Filter(filters, true);


SVApplications.Output("Found " + lstreturn.Count.ToString() + " ocurrences");


foreach(string str in lstreturn)

{

            object objVal = SVTags.GetValue(str);

            int tagVal = (int)objVal;

            SVApplications.Output("Value read from tag " + str + " = " + tagVal.ToString());

}

 



.     We are creating a dictionary and adding to it a filter where all the tags with the *NewTag* text on the name must have value from 1 to 5. The result will be written to the output log. We also use the SVTags.GetValue function to return the tag's value.


.     Now let's run a test.


.     Run the Application (F5) and see the results.


graphic



.      Open the Data Watcher.

            

graphic



.     Add the 10 tags to the data watcher as in the image below:


.     Also define values to NewTag2, NewTag4, NewTag6, NewTag8, NewTag10 (from 1 to 5). These tags will be the ones filtered.


graphic



.    Open your graphic and click the "Check" button.


graphic



.     The result will be written to the output log.


.     As you can see, the Filter function returned the tags correctly. Then we used the GetValue function to check their values.


graphic