Variable comparisons in constraints

jagg

New member
Hi, when using a constraint you cannot compare two variables. For example as a constraint I can say when boolean1 = false but I cannot say boolean1 = boolean2 as a constraint. This would be a helpful feature as I find myself in situations where I would like to set this as a constraint. Thanks in advance.
 

fmcpma

Member
Sure you can! After selecting the first variable in the first dialogue, select the Variable option in the second dialogue and the second variable you want in the drop-down menu right below. Of course, at the top select the equality option (or any of the other three). If you need anything more complicated, choose the Expression option instead and enter the expression the first variable must be equal to (or greater than, etc.) You even have magic text there to help you.
 

Endercraft

Moderator (& bug finder :D)
Sure you can! After selecting the first variable in the first dialogue, select the Variable option in the second dialogue and the second variable you want in the drop-down menu right below. Of course, at the top select the equality option (or any of the other three). If you need anything more complicated, choose the Expression option instead and enter the expression the first variable must be equal to (or greater than, etc.) You even have magic text there to help you.
I think you are talking about the set variable action, and not the variable constraint for boolean variables. It does indeed only offer true or false.
 

fmcpma

Member
Actually I was talking about the constraint and I was testing it in my phone as I was writing. I just didn't realize that a) jagg was only interested in boolean variables for his constraint (that was not very clear from his post) and b) variable constraints are indeed very poor for boolean vars as opposed to constraints for integer (which I was testing with), string and decimal vars, which I also didn't realize.

As such, my answer was inadequate.

All I can suggest then, to solve jagg's problem, though this is long-winded and awkward, is the following:

1. Create a AND/OR/XOR/NOT constraint (Macrodroid Specific) and select the OR option.

2. Add two more AOXN constraints as children of the first one – touch the constraint just created and select Add constraint. This time leave the default AND option selected. (Just don't add the third constraint to the second one but also to the first.)

3. Add two variable constraints as children of the first AND constraint. In the first of these select your boolean1 var and leave the "= False" option selected. In the second, select your boolean2 variable and again leave the "= False" option selected.

4. Now add two further variable constraints as children of the second AND constraint. In the first of these select your boolean1 var and then select the "= True" option. In the second, select your boolean2 variable and again select the "= True" option.

There you go! What all this boils down to is that for the first/master/boss/grandparent constraint to be true it is necessary that either both boolean variables be False or both be True; in other words, they must be equal!

Hope this helps, jagg.
 

jagg

New member
That's actually a interesting solution that does indeed work, thank you. However in terms of convivence, I still think it would be nice to see a simple bool1 = bool2 logic in constraints/if statements similar to those of other variable types.
 

jagg

New member
It seems this feature has been added in the latest update under "compare values". Many thanks.
 

fmcpma

Member
Yes, just seen it. Was about to suggest it to you. But I still think the Macrodroid Variable constraint for boolean variables should work the same as for the other types of variable.
 
Top