mIRC Home    About    Download    Register    News    Help

Print Thread
if elseif else statement #268313 02/01/21 09:06 PM
Joined: Jan 2021
Posts: 1
B
Baeyens Offline OP
Mostly harmless
OP Offline
Mostly harmless
B
Joined: Jan 2021
Posts: 1
Hey mIRC team and Users,

is was wondering if anyone could help me and if the developers could check this out.
the if, elseif and else statement.
I've got some issues with it.
On the help page the first thing i read is
Quote

Basic format
if (v1 operator v2) { commands }
elseif (v1 operator v2) { commands }
else { commands }


So i tried
Quote

on *:TEXT:*:#: {
if ($1 === Yo){/msg $chan hi}
elseif ($1 === That){/msg $chan ok}
else {/msg $chan forget it}
}


But that failed.
While reading further and experimenting
i found the bottom partial script code to be working.
Can someone explain this to me, why this difference in statement?

Re: if elseif else statement [Re: Baeyens] #268317 03/01/21 12:36 PM
Joined: Oct 2017
Posts: 41
D
DooMaster Offline
Ameglian cow
Offline
Ameglian cow
D
Joined: Oct 2017
Posts: 41
You need to add a space on
Code
){/msg $chan hi }


So use:

Code
) { /msg $chan hi }


Check and use the format as you see in the examples exactly, you can see more examples in the online wiki https://en.wikichip.org/wiki/mirc

Re: if elseif else statement [Re: Baeyens] #268319 03/01/21 01:03 PM
Joined: Jul 2006
Posts: 3,773
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,773
You need space around { and } (though } don't need a space on it's right if it terminates the line/file)


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net