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 

How to enclose "or" conditions into one condition?

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


Joined: 27 Jun 2014
Posts: 37

PostPosted: Sun Jul 27, 2014 6:51 am    Post subject: How to enclose "or" conditions into one condition? Reply with quote

This is the line I'm having trouble with:

Code:
if {[string match -nocase "abc" $txt] || [string match -nocase "def" $txt] || [string match -nocase "ghi" $txt] || [string match -nocase "jkl" $txt] && $nick eq "daigo"}


Whenever someone says "abc" "def" or "ghi" the script responds to them, even though I stated that I want only the nickname "daigo" to be responded to. I assume this is because I need to enclose all 4 of the || conditions together, but I tried brackets [], {} and parentheses () but none of them work.
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Sun Jul 27, 2014 9:14 am    Post subject: Re: How to enclose "or" conditions into one condit Reply with quote

daigo wrote:

...
and parentheses () but none of them work.


I think parenthesis work.

Show us the line of code, exactly as you used it, that utilizes parenthesis.
Back to top
View user's profile Send private message
Get_A_Fix
Master


Joined: 07 May 2005
Posts: 206
Location: New Zealand

PostPosted: Sun Jul 27, 2014 10:04 am    Post subject: Reply with quote

The parenthesis are necessary when you're using "".

For example, if I needed two conditions in an IF statement, ending in "", I would then use ( ) to keep it closed.

Code:

if {[lindex [split $arg] 0] ne ""} {
if {[string match -nocase "*matchthis*" $arg]} {


would then become

Code:

if {([lindex [split $arg] 0] ne "") && ([string match -nocase "*matchthis*" $arg])} {


This would fix your issue with the last condition of your statement; $nick eq "daigo"
_________________
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Sun Jul 27, 2014 10:22 am    Post subject: Reply with quote

Try it like this...
Code:
if {([string match -nocase "abc" $txt] || [string match -nocase "def" $txt] || [string match -nocase "ghi" $txt] || [string match -nocase "jkl" $txt]) && $nick eq "daigo"}

_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Back to top
View user's profile Send private message Visit poster's website
daigo
Voice


Joined: 27 Jun 2014
Posts: 37

PostPosted: Sun Jul 27, 2014 11:01 am    Post subject: Reply with quote

Oh, this works..I thought I tried this already, but I must've made a typo somewhere.
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Sun Jul 27, 2014 11:16 am    Post subject: Reply with quote

daigo wrote:

...
I thought I tried this already, but I must've made a typo somewhere.


That's why I asked for your exact code, as you used it. Smile
Back to top
View user's profile Send private message
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