mIRC Home    About    Download    Register    News    Help

Print Thread
I
iRP
iRP
I
I was scripting and I discovered a parsing problem with the $iif function. When you enter //echo -a $iif((1) echo -a hello,bye) it will output "hello return 1". I am not sure if this a bug or not because if you enter //echo -a $iif((0) echo -a hello,bye) nothing happens. I just thought I would let you know...

Joined: Feb 2004
Posts: 2,013
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Feb 2004
Posts: 2,013
You are getting weird results because you misuse $iif.

$iif(condition,true,false)

You forgot to put a comma after the condition, to seperate the condition from the actions. Also it's not a good idea to use brackets in an identifier like that, they aren't needed even.

What you are looking for is:

//echo -a $iif(0,echo -a hello,bye)
//echo -a $iif(1,echo -a hello,bye)

which are both processed correctly.

Even using brackets, it gave the required result:

//echo -a $iif((0),echo -a hello,bye)
//echo -a $iif((1),echo -a hello,bye)

which were both processed correctly.

However, don't use brackets in the if condition nevertheless.

Greets

Joined: Jan 2003
Posts: 2,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
Looks like a bug. Even though you used $iif() incorrectly, it should give an error (or at least return $null), not execute a command.

I
iRP
iRP
I
I know the correct syntax for $iif is $iif(condition,t,f) but I am just showing you a bug of what happens when you enter //echo -a $iif((1) echo -a test,t) just incase it is not misused in the future.


Link Copied to Clipboard