Page 1 of 1

IfEx Broken?

PostPosted: Sat Nov 01, 2014 1:12 pm
by TMcD
I've tried both of these and they both end up setting [test] to Triggered

Anyone know why?

Code: Select all
SetVar "[datecheckednumber]" "6"
IfEx "[datecheckednumber] <> 0 OR [datecheckednumber] <> 6"
SetVar "[test]" "Triggered"
EndIf


Code: Select all
SetVar "[datecheckednumber]" "6"
IfEx "[datecheckednumber] <> [#34]0[#34] OR [datecheckednumber] <> [#34]6[#34]"
SetVar "[test]" "Triggered"
EndIf

Re: IfEx Broken?

PostPosted: Sat Nov 01, 2014 1:49 pm
by Gaev
Troy:

When you ...
Code: Select all
SetVar "[datecheckednumber]" "6"

... then ...
Code: Select all
IfEx "[datecheckednumber] <> 0 OR [datecheckednumber] <> 6"

... will resolve to ...
Code: Select all
IfEx (true) OR (false)

... and since OR means ...
"if at least one of the two sides is (true), then the result is (true)"

... the result is (true) ... and hence [test] is set to "Triggered"

From your other post about Day Of Week, I think you are looking for ...
Code: Select all
IfEx "[datecheckednumber] <> 0 AND [datecheckednumber] <> 6"


BTW, it is safe practice to ...
Code: Select all
SetVar "[test]" "something else"

... before doing the IfEx code block ... so when it is NOT (true), you won't be confused with any previous value of "Triggered"

Re: IfEx Broken?

PostPosted: Sat Nov 01, 2014 1:58 pm
by TMcD
Thanks Gaev (again) :D

Changing OR to AND works.

But I find my thinking seemed correct.

Code: Select all
IfEx "[datecheckednumber] <> 0 OR [datecheckednumber] <> 6"


That means:

If [datecheckednumber] is not equal to 0, OR If [datecheckednumber] is not equal to 6
DO THIS
EndIf

Re: IfEx Broken?

PostPosted: Sat Nov 01, 2014 2:55 pm
by Gaev
Troy:

In Logic ...

1) ConditionA OR ConditionB will yield the following results ...

ConditionA is false. ConditionB is false ... result is false
ConditionA is false. ConditionB is true ... result is true
ConditionA is true. ConditionB is false ... result is true
ConditionA is true. ConditionB is true ... result is true

2) ConditionA AND ConditionB will yield the following results ...

ConditionA is false. ConditionB is false ... result is false
ConditionA is false. ConditionB is true ... result is false
ConditionA is true. ConditionB is false ... result is false
ConditionA is true. ConditionB is true ... result is true

Also, remember that you can often make life easier by setting up a condition block that DOES NOTHING e.g. ...
Code: Select all
IfEx "[datecheckednumber] = 0 OR [datecheckednumber] = 6"
   ... Sunday or Saturday
   ... do nothing
Else
   ... Monday to Friday
   SetVar "[test]" "Triggered"
EndIf

Re: IfEx Broken?

PostPosted: Sun Nov 02, 2014 8:13 pm
by TMcD
Thank you very much, I'll have to drill that in my head. :roll: :lol: