egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Multiple if $nicks? [SOLVED]

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
DJCharlie
Voice


Joined: 06 May 2009
Posts: 37

PostPosted: Thu Jun 17, 2010 12:31 pm    Post subject: Multiple if $nicks? [SOLVED] Reply with quote

Ok, say I've got this bit of code:

Code:
  if {$nick == "DJCharlie"} {
  ...rest of proc goes here...
  }


What I'd like, is to check if the nick is DJCharlie OR another authorized nick. Is that possible? If so, how?

Thanks in advance!


Last edited by DJCharlie on Fri Jun 18, 2010 3:20 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Thu Jun 17, 2010 3:29 pm    Post subject: Reply with quote

To use the logical OR in a conditional, do something like this:
Code:
...
if {conditional1 || conditional2} {
...

Where conditional1 would be one conditional such as $nick == "DJCharlie".

In the case you'd like to test one variable against multiple values, this could be optimized using the switch command:
Code:
...
switch $nick {
  "DJCharlie" -
  "NML_375" -
  "SomeOtherDude" {
    ...
  }
}
..

In this case, the - means "use the next match", which allows us to stack an infinite number of cases to use the same code.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
DJCharlie
Voice


Joined: 06 May 2009
Posts: 37

PostPosted: Fri Jun 18, 2010 3:19 pm    Post subject: Reply with quote

That fixed it, thanks!
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
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


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber