mIRC Home    About    Download    Register    News    Help

Print Thread
#60128 13/11/03 07:07 AM
Joined: Apr 2003
Posts: 426
Fjord artisan
OP Offline
Fjord artisan
Joined: Apr 2003
Posts: 426
I'm just wondering if its possible to run multiple commands inside an $iif statement when a condition returns true or false (or whatever you've got it to return/check as).

eg, $iif($network == BlahNet, echo -a boo | .hadd networks blah)


--------
mIRC - fun for all the family (except grandma and grandpa)
#60129 13/11/03 08:48 AM
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
Code:
$iif($network == BlahNet, one, two)
alias one { echo -a boo | .hadd networks blah }
alias two { echo -a bah | .hadd networks blurg }


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
#60130 13/11/03 09:57 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
The question is, why do you want to do that? $iif() is meant to return a value (that will be used as a parameter to a command) based on a condition, not execute commands. Of course, you can still use it for things like

$iif($isid,return,echo -a) %result

but this is indeed shorter thar the equivalent

if $isid { return %result }
echo -a %result

because of the common factors (%result here) that don't have to be typed twice. But multiple commands in $iif()? You don't save any space this way. Instead, you make the code unecessarily complex. Why not just use plain /if ? It's cleaner, better for this job and faster.

Oh btw, there is no way to do multiple commands, except for hacks like this:

$iif(1 == 1,scid -r echo -a one $chr(124) echo -a two)

but you may find the extra evaluation caused by /scid annoying.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#60131 13/11/03 02:44 PM
Joined: Apr 2003
Posts: 426
Fjord artisan
OP Offline
Fjord artisan
Joined: Apr 2003
Posts: 426
This is a generic reply:

LocutosOfBorg: Yes, I had actually thought of that, but for what I need it to do, its kind of pointless.

Qwerty, I hadn't thought of doing that, but anyway.

However, yes, whilst $iif is only "meant" to return a T/F flag or value, it can be used to run commands.
mIRC interprets whatever is in the T position to be returned whenever an item is true, thus, if a command is placed there, it gets run, the same is said for false data. Whether or not this is the default behaviour or not, it doesn't matter, all I know is that its possible to execute commands from the $iif, and I love it. In fact, $iif has almost become my scripting best friend smile (Sad isn't it :P)

*edit addendum*
Oh, I also love the fact that it makes it really easy to evaluate things on the fly in the editbox before commiting the script to disk. Of course one can do this other ways, but I like to be slightly different.

$iif($identifier meets $condition, lets play ball, return)

I use $iif simply because it is a whole lot quicker to type it out in some cases than to go into an extremely unecessary four line if statement (trust me, I'd rather get it done in one line and half the characters than in 4 times the lines, and so on).

For the moment, I've just decided to use multiple $iif statements.

And trust me, if you'd seen the length of my configuration dialog statments before I changed all I could over to $iif, then you'd understand why I did. I literally cut the length down by three quarters.


--------
mIRC - fun for all the family (except grandma and grandpa)
#60132 13/11/03 10:34 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
"However, yes, whilst $iif is only "meant" to return a T/F flag or value, it can be used to run commands."

You're right--partially. Though commands are executed based on the outcome of the if, the iif itself does not run commands. So now that being said, how you can make an alias that doesn't already execute a command, have the ability to "execute more than one command"? The key part would be more, as it doens't alreayd do so.


-KingTomato
#60133 14/11/03 12:24 AM
Joined: Apr 2003
Posts: 426
Fjord artisan
OP Offline
Fjord artisan
Joined: Apr 2003
Posts: 426
I didn't phrase very well.

What I mean, is being able to use the | to run more than one command when something returns true or false within the $iif.
Kind of like how you can use it to break up commands so they all sit on one line...


--------
mIRC - fun for all the family (except grandma and grandpa)

Link Copied to Clipboard