mIRC Homepage

$iif in $findfile

Posted By: aca20031

$iif in $findfile - 03/05/08 08:07 PM

Code:
//tokenize 32 Testing | noop $findfile($mircdir,*,1,echo -a $1-)


Echos the file path as expected

Code:
//tokenize 32 Testing | noop $findfile($mircdir,*,1,$iif($true,echo -a $1-,))


Echos Testing instead of the file path
Posted By: qwerty

Re: $iif in $findfile - 03/05/08 08:26 PM

Indeed. The actual problem is that whenever the [command] parameter of $findfile starts with an identifier/variable, mirc evaluates that parameter an extra time:

//var %a = ec $!+ ho | tokenize 32 Testing $!version | noop $findfile($mircdir,*,1,%a $1-)
echoes "Testing 6.31", indicating that %a and $1- were 'pre-evaluated' once, so that $findfile executes the result of that first evaluation (and as it does, it (re)evaluates the contents like normal).

This also poses a security risk, in cases where $findfile is used like that inside an on TEXT event or any other place where $1- contains unknown content.
© 2022 mIRC Discussion Forums