IfEx issue - Forum

Forum Navigation
You need to log in to create posts and topics.

IfEx issue

Hi,

I'm new to the forum and I have an issue with this code.

SetVar "[color]" "pink"
.SetVar "[color]" "red"

IfEx "[color] <> pink OR [color] <> red"
  AlertBox "Alert" "No color chosen."
Else
  AlertBox "Alert" "Color chosen is [color]."
EndIf

 

Even with the [color] variable set to "pink", the AlertBox "No color chosen" comes up.

 

 

 

@naomi

IfEx "[color] <> pink OR [color] <> red"

Even with the [color] variable set to "pink", the AlertBox "No color chosen" comes up.

You have used the Logical Operator OR ... this means that if any one of the conditions is true, the IfEx condition is considered true.

So, when [color] is set to "pink", it is not "red" ... hence the second condition is true ... hence the IfEx returns a true.

Try this ...

IfEx "[color] <> pink AND [color] <> red"

... now when [color] is red or pink, it will return a false, but if it were (say) green, both conditions will be true and IfEx will return a true.

@gaev

Thankyou.