jaytea commented on a Page, $ieif  -  Aug 11, 2011

i really like these kind of ideas ;) unfortunately, they're usually too difficult (and in this case, impossible) to get right owing to the 'special' nature of mIRC's interpreter.

when you use $iif(EXP, t, f), mIRC takes the first parameter 'EXP' and inserts it, without any evaluation, directly into an if statement as 'if (EXP)'. that's how $iif($(1 == 2), y, n) is able to return 'y' (with $v1 = '1 == 2'). but, as you've probably discovered, there's no way to determine whether the user passed '1 == 2' or '$(1 == 2)' as the condition.

then there's the issue of double evaluations, which you've quite admirably attempted to handle by inserting those '!' chars. but what about variables, evaluation brackets, parentheses, commas and, on the flip side, '$' used as part of plaintext? ;P you could get around all this by first dissecting the condition manually: find the operator and take everything on the left as v1 and everything on the right (if it exists) as v2. then you can set up the condition as '%v1 op %v2' such that '%v1' and '%v2' evaluate to produce the given values. only bad thing about this is you'll have to do a bit of tedious work to accommodate multiple conditions separated by && and/or || in a single parm. could be a fun exercise ;D

about that $v1 / $v2 problem: i'm not sure what you would expect $v1 and $v2 to return if $prop is 'true' or 'false', but if you switch '[ %x ]' and '!$prop' around on that 5th line, and transform the last line into a couple of if statements to force $v1 and $v2 to be filled in the 'else' case, $v1 and $v2 will be filled correctly after a call to $ieif(). having $v1 and $v2 filled inside a call to $ieif() is not possible though, since the args passed to $ieif() will always evaluate before the alias is called.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.