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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Ralph1971
Wanderer


Joined: 01 Mar 2008
Posts: 64

PostPosted: Tue May 17, 2011 4:05 pm   

variable comparison
 
I'm looking to try to compare variables in 2 ways..
variables.. line1, line2, line3
first comparison..
line1=line2 and line1=line3.. (all three same thing) one thing happens
line1=line2 OR line1=line3 OR line2=line3 (any 2 the same) different thing happens
the three way comparison is throwing me for a loop.. is there an efficient way of doing that?
_________________
Win7-home - Cmud 3.33a
WinXP-pro - Zmud 7.21
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue May 17, 2011 7:59 pm   
 
Sure. There are two obvious ways. The first is to put the second #IF statement within the ELSE portion of the first #IF statement. The second option is to use a #SWITCH command. Since there are only two choices, I would probably do the first option:
Code:

#IF (line1=line2 AND line1=line3) {
  one thing happens
} {
  #IF (line1=line2 OR line1=line3 OR line2=line3) {
    different thing happens
  }
}
Reply with quote
Ralph1971
Wanderer


Joined: 01 Mar 2008
Posts: 64

PostPosted: Tue May 17, 2011 10:01 pm   
 
Ok, haven't tried that witch cmud yet, but zmud really didn't like the OR's... I'll shoot for cmud and see what happens
_________________
Win7-home - Cmud 3.33a
WinXP-pro - Zmud 7.21
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed May 18, 2011 1:31 am   
 
In zmud you would use & for AND and | for OR. In Cmud, you would use AND or &&, and OR or ||. See this page from the Changes For Zmud Users:
http://forums.zuggsoft.com/modules/mx_kb/kb.php?page=3&mode=doc&k=2625
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed May 18, 2011 3:30 am   
 
AND/OR are standard to both apps. The only difference came in the shortcuts of &/&& and |/||.
_________________
EDIT: I didn't like my old signature
Reply with quote
martyall
Newbie


Joined: 17 May 2011
Posts: 3

PostPosted: Wed May 18, 2011 4:07 am   
 
Thanks MattLofton. You really give me ideas. Thanks for your valuable information. :D
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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