|
Venka Beginner
Joined: 02 Aug 2007 Posts: 10
|
Posted: Sat Nov 01, 2008 9:52 am
probably a really simple error |
Hi :)
I am having problems with this:
#if (@bzkdr < 10 OR @achrs < 4) {#EC You need to SCAR!}
What I want it to do is ECHO if either variable is true, but that is not what is happening. It seems to only work when the first variable is true.
I probably am not understanding OR. Any help would be greatly appreciated.
Thanks! |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sat Nov 01, 2008 10:25 am |
I never trust the order of operations in any language. It is a good habit to add extra parenthesis to make sure you get what you want.
#if ((@bzkdr < 10) OR (@achrs < 4)) {#EC You need to SCAR!} |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Sat Nov 01, 2008 1:54 pm |
I agree with Vij, its a bit paranoid, but unless you've yourself thoroughly tested a language for proper OrderOps, don't trust it. Heck, the only language I trust it in to this day is C
|
|
_________________ CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
|
Zhiroc Adept
Joined: 04 Feb 2005 Posts: 246
|
Posted: Sat Nov 01, 2008 2:06 pm |
I can't reproduce that problem, extra parens or no (and I've never parenthesized such a simple expression, so I doubt that's the issue). I would check that @achrs really does hold the number you think it does, and isn't a string of some sort (#SH {|@achrs|} is a good way to check), and that you don't have more than one variable of this name and the script is picking up the wrong one (try doing that #SH in the false clause of that #if, for example).
|
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Sat Nov 01, 2008 6:13 pm |
Another thing you can do is above your #IF in your alias or trigger put:
#ECHO Value 1: @bzkdr
#ECHO Value 2: @achrs
#ECHO Testing Values Compared To 10 And 4 Respectively
Then during your testing phase you can always see what the 2 vars are every time the IF is called. |
|
_________________ CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
|
Venka Beginner
Joined: 02 Aug 2007 Posts: 10
|
Posted: Sat Nov 01, 2008 8:39 pm |
Thank you Vijilante!
Putting the extra brackets fixed it. Yay - now it is working perfectly.
Thank you so much. |
|
|
|
|
|