Source language: Translate to:

IfEx Broken?

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

IfEx Broken?

Postby TMcD » Sat Nov 01, 2014 1:12 pm

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
TMcD
 
Posts: 237
Joined: Sun Apr 10, 2005 11:20 am

Re: IfEx Broken?

Postby Gaev » Sat Nov 01, 2014 1:49 pm

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"
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: IfEx Broken?

Postby TMcD » Sat Nov 01, 2014 1:58 pm

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
TMcD
 
Posts: 237
Joined: Sun Apr 10, 2005 11:20 am

Re: IfEx Broken?

Postby Gaev » Sat Nov 01, 2014 2:55 pm

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
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: IfEx Broken?

Postby TMcD » Sun Nov 02, 2014 8:13 pm

Thank you very much, I'll have to drill that in my head. :roll: :lol:
TMcD
 
Posts: 237
Joined: Sun Apr 10, 2005 11:20 am


Return to NeoBook Action Commands

Who is online

Users browsing this forum: Bing [Bot] and 1 guest