Hello Forum,
I am trying to determine the name of a variable based on the value of the variable, For example in:
Let>green_alarm=ssh
Let>red_alarm=http
I need a code construct to determine which variable has the value "http" without having to perform an explicit 'if' check on each variable. For simplicity the variable values in my example are static, but in my actual use-case the value of the variables will be calculated (dynamic). Is there a "find" type of command to accomplish this?
Thank you
Determining the variable name
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Determining the variable name
It sounds like what you really want is an array, but instead of an array indexed by numbers, indexed by a string which in this case is a colour. If we call it alarm_ and we have array entries alarm_green and alarm_red we could have an array of the index names (green, red, ...) then we could use some loops to do your "FIND". You'd need an array for the index names, and a repeat/until loop for the main array, which stops when found.
Sent from my iPad using Tapatalk
Sent from my iPad using Tapatalk
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: Determining the variable name
Marcus,
Thank you!
Aaron
Thank you!
Aaron
Re: Determining the variable name
Not sure if this would work for you but one way could be to pull the variable names and values into a string and then use RegEx to search for the variable name.
View Snippet Page
View Snippet Page