Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Venka
Beginner


Joined: 02 Aug 2007
Posts: 10

PostPosted: 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!
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: 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
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: 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
Reply with quote
Zhiroc
Adept


Joined: 04 Feb 2005
Posts: 246

PostPosted: 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).
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: 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
Reply with quote
Venka
Beginner


Joined: 02 Aug 2007
Posts: 10

PostPosted: 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.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net