mIRC Homepage


Posted By: HaleyJ

$eval - 25/08/06 10:12 PM

I would like to understand what the identifier $eval does, i looked in the help file and didnt really understand. I have seen it being used in alot of scripts here. Also is it possible to give an example.

The same goes for regex i have seen used alot but dont understand.
Posted By: hixxy

Re: $eval - 25/08/06 10:27 PM

Put this in your variables tab and hit the ok button:

%a %b
%b %c
%c %d
%d %e
%e 5

Then type:

//echo -a $eval(%a,0) ~ $eval(%a,1) ~ $eval(%a,2) ~ $eval(%a,3) ~ $eval(%a,4) ~ $eval(%a,5)

The output is:
%a ~ %b ~ %c ~ %d ~ %e ~ 5

$eval(%a,0) evaluates %a 0 times, so it stays as "%a", without being interpreted as a variable at all.
$eval(%a,1) evaluates it once, so it will return %b, without evaluating %b
$eval(%a,2) will first evaluate %a to %b, and then %b to %c, because it's evaluating twice.
$eval(%a,3) will do %a to %b, then %b to %c, then %c to %d
$eval(%a,4) will do %a to %b, then %b to %c, then %c to %d, then %d to %e
$eval(%a,5) will do %a to %b, then %b to %c, then %c to %d, then %d to %e, then %e to 5.
Posted By: SCNDRL

Re: $eval - 25/08/06 11:16 PM

//set $+(%,me!,$me) $me

%me!SCouNDReL is $me now After that try them ;

//echo -a $eval($+(%,me!,$me),0) or //echo -a $($+(%,me!,$me),0)
//echo -a $eval($+(%,me!,$me),1) or //echo -a $($+(%,me!,$me),1)
//echo -a $eval($+(%,me!,$me),2) or //echo -a $($+(%,me!,$me),2)
Posted By: Rand

Re: $eval - 26/08/06 11:28 AM

As hixxy was pointing out, $eval() will go through the contents and evaluate it to the amount of times you specify.

So if you specify $eval(<text>,0) nothing in $eval() will be evalauated.

If you specify $eval(<text>,1) it will be evaluated once. If you specify $eval(<text>,2) it will be evaluated twice.

As a decent example, in your editbox, you can type (With just ONE backslash):

Let's say your nick is "Peachy"

/set %mynick $me

Then type: //echo -a %mynick

This is only evaluating "%mynick" once, so you will see "$me" as the echo.

Typing: //echo -a $eval(%mynick,0) : will not evaluate %mynick at all, so the only thing echo'ed is "%mynick"

Typing: //echo -a $eval(%mynick,1) : will echo "$me" because it only evaluates the variable, and not what is inside the variable.

Typing: //echo -a $eval(%mynick,2) : will echo "Peachy" because it evaluates %mynick, which is $me, and then evaluates a second time, which turns $me into your nick "Peachy".
Posted By: HaleyJ

Re: $eval - 26/08/06 12:18 PM

Thanks you have all been very helpful.
© 2019 mIRC Discussion Forums