mIRC Home    About    Download    Register    News    Help

Print Thread
#167027 18/12/06 08:34 PM
Joined: Apr 2005
Posts: 1,008
R
raZOR Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Apr 2005
Posts: 1,008
can an alias or some event have 2 groups of IF+ELSEIF

like:

alias something {
if
elseif
/somecommand
/somecommand2
if
elseif
/somecommand3
}

?

raZOR #167028 18/12/06 08:49 PM
Joined: Dec 2002
Posts: 2,884
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,884
Yes. It can have as many as you want.

raZOR #167029 18/12/06 09:01 PM
Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
Just make sure you don't get confused with too many of them. smile

Riamus2 #167030 18/12/06 09:08 PM
Joined: Apr 2005
Posts: 1,008
R
raZOR Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Apr 2005
Posts: 1,008
hehe, i wont ^^

i was more confused how the thing works...
i know you can have:

if
if
if
------------
if
elseif
else
------------
if
else
------------

but dual if + elseif kinda looks weird O_o



raZOR #167034 18/12/06 09:21 PM
Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
Heh. It works fine as long as you don't start nesting the IFs inside each other by accident.

if { }
elseif { }
elseif { }
else { }
if { }
if { }
else { }
if { }
elseif { }
else { }
if { }

That will work just fine.

Riamus2 #167039 19/12/06 12:03 AM
Joined: Oct 2003
Posts: 284
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Oct 2003
Posts: 284
No reason not to nest them:

Code:
 
if ($network == MyNet) {
  echo -a It's MyNet
  if ($chan == #MyChan) {
    echo -a ...and I'm on #MyChan
  }
  elseif ($chan == #YourChan) {
    echo -a ...but I'm on #YourChan
  }
}
else {
  echo -a No idea what Net I'm on
}


Note how much the indenting helps to work out which if/else combinations are associated.

Sais #167041 19/12/06 12:30 AM
Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
"by accident" smile

Riamus2 #167060 19/12/06 09:52 AM
Joined: Oct 2003
Posts: 284
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Oct 2003
Posts: 284
It was late, I was tired, I didn't read the whole thing...

That's my story, and I'm sticking to it laugh

(Sorry)

Last edited by Sais; 19/12/06 09:53 AM.

Link Copied to Clipboard