Support Forums
Sorting arrays of tags

Hi,

I'd like to use an array of tags and order it by different characteristics in script (ex. the tags with an active alarm first).

I think the best way to achieve this is by using the function GetTagList then sort that array. Unfortunately GetTagList only return an array of tag names so I can't access the tags properties. In order to sort them I would need a function that return a tag property.

I also tried to get the list of alarm tags thinking I could use that list to see which tag have active alarms but using "Alarm" as a tagType isn't working (\GetTagList("CommunAncestorName"\ShortName, TRUE, 0, "*", "Alarm" ); )

Is there a solution for my problem?

Thank you

Hi, I'd like to use an array of tags and order it by different characteristics in script (ex. the tags with an active alarm first). I think the best way to achieve this is by using the function GetTagList then sort that array. Unfortunately GetTagList only return an array of tag names so I can't access the tags properties. In order to sort them I would need a function that return a tag property. I also tried to get the list of alarm tags thinking I could use that list to see which tag have active alarms but using "Alarm" as a tagType isn't working (\GetTagList("CommunAncestorName"\ShortName, TRUE, 0, "*", "Alarm" ); ) Is there a solution for my problem? Thank you
edited Feb 6 '18 at 1:31 pm

Could you accomplish what you are looking for using the built-in Tag List Widget or the Alarm List Widget?

Could you accomplish what you are looking for using the built-in [Tag List Widget](https://www.trihedral.com/help/Content/D_Widgets/Dev_TagListWidget.htm) or the [Alarm List Widget](https://www.trihedral.com/help/Content/D_AlarmSystem/Dev_AlarmList.htm)?

Trihedral Engineering Ltd.

I don't think so.

I need to display an arbitary amount of widgets linked to my typical dataset. That amount will change dynamically, that is why I think they need to be in a list. Also I want to be able to sort them by alarm so the operator will see where his attention need to be fast. I don't need to display the alarms, I just need to know which widgets have active alarms.

My current solution is to create a tag name list with GetTagList(), then I use AlarmManager\GetAlarmStateStats on each tag in my list to create another list of alarm stats for each tag. What I lack is a way to sort my first list (my tag list) depending on the content of the other list (the alarm stats list). Do you think I could use SortArray() for that, or should I make a sub-module as a sorting function?

Thank you for you help

I don't think so. I need to display an arbitary amount of widgets linked to my typical dataset. That amount will change dynamically, that is why I think they need to be in a list. Also I want to be able to sort them by alarm so the operator will see where his attention need to be fast. I don't need to display the alarms, I just need to know which widgets have active alarms. My current solution is to create a tag name list with GetTagList(), then I use AlarmManager\GetAlarmStateStats on each tag in my list to create another list of alarm stats for each tag. What I lack is a way to sort my first list (my tag list) depending on the content of the other list (the alarm stats list). Do you think I could use SortArray() for that, or should I make a sub-module as a sorting function? Thank you for you help

I found a way to do what I wanted to do. I made a sub module as a sorting function and I call it whenever I need to sort an array.

Thank you Dave for the inputs and support smile

I found a way to do what I wanted to do. I made a sub module as a sorting function and I call it whenever I need to sort an array. Thank you Dave for the inputs and support :)
145
3
3
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft