Page 1 of 1

Multiple values possible for "becomes equal to" ?

PostPosted: Sat Apr 27, 2019 2:53 pm
by sumocomputers
Please see screenshots.

I want the value of variable B to change based on the value of variable A.

Variable A can have values of 01-31.

On this particular trigger, I want values of 01, 21, & 31 of Variable A to trigger a change of Variable B to "st".

I am using "becomes equal to:" with commas as separators, but it doesn't seem to be working correctly.

Is what I am trying to do even possible? If so, am I using the incorrect separator?

I know I could make a separate trigger for every possible value between 01-31 or maybe use conditions, but was trying to do less manual work.

2.jpg
2.jpg (254.09 KiB) Viewed 1573 times


1.jpg
1.jpg (241.55 KiB) Viewed 1573 times

Re: Multiple values possible for "becomes equal to" ?

PostPosted: Sun Apr 28, 2019 4:07 am
by DaveL17
I could be wrong, but I don't think Indigo will evaluate based on a list like that (although that would be an awesome feature). I suspect that it will evaluate the list literally--that is, your trigger will only fire when the variable becomes equal to the entire list.

If it were me, I would do the following which still gets you the same behavior with one trigger:

Trigger: variable changes
Condition: if conditions match rules:
any
- variable foo is equal to value 1
- variable foo is equal to value 21
- variable foo is equal to value 31

Re: Multiple values possible for "becomes equal to" ?

PostPosted: Sun Apr 28, 2019 7:49 am
by sumocomputers
Thanks for confirming. I used conditions as you suggested, and it works great.

The "th" was a lot of clicking. 120 clicks to be exact, lol.

3.jpg
3.jpg (427.55 KiB) Viewed 1518 times

Re: Multiple values possible for "becomes equal to" ?

PostPosted: Mon Apr 29, 2019 9:43 am
by jay (support)
Or, here's a little Python script snippet I found:

Code: Select all
day = indigo.variables[IDFORDAYNUM].getValue(int)
suffix = ""
if 4 <= day <= 20 or 24 <= day <= 30:
    suffix = "th"
else:
    suffix = ["st", "nd", "rd"][day % 10 - 1]
indigo.variable.updateValue(IDFORSUFFIXVAR, value=suffix


Not tested fully, but it's pretty close. Then you just execute the script for any change to the source variable.

Re: Multiple values possible for "becomes equal to" ?

PostPosted: Mon Apr 29, 2019 5:12 pm
by sumocomputers
Thanks Jay, I'll give it a go.