mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2003
Posts: 282
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
What does $eval do, and how do I use it?
What does evaluation means in mIRC??, why does some thing needs to be evaluated more than 1 time: $eval(%a= $cid ,5)
Why does there is an option to do no evanuation: $eval(%a=$cid,0), can I just write %a =$cid ???



Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Usually $eval() is used to either evaluate something 2 times or 0 times.

Scenario for evaluating something 2 times:
Most commonly needed with script-derived variable names.
In a channel stats script say it logged the number of lines someone spoke in a particular channel. It'd use something like inc $+(%,stats.,$network,.,$chan,.,$nick) so that it was specific to that network on that channel for that nick. Now, when you need to get the value of that variable via a script, using $+(%,stats.,$network,.,$chan,.,$nick) again will only return the name of the variable (something like %stats.dalnet.#moomoomoo.starbucks) - not the value. So, you'd use $eval([color:green]$+(%,stats.,$network,.,$chan,.,$nick),2)[/color] so that the contents was evaluated twice - once to get the variable name, and then the second time to evaluate that variable name to get it's value.

Scenario for evaluating something 0 times:
Most commonly used with certain commands that take other commands as parameters (eg. /timer or /scon)
If I wanted a /timer that /echo'd the time that it began and the time that it stopped.
Using /timer 1 10 echo -a $time $time would simply echo the time it started twice since the identifiers would all be evaluated at the time I typed the command. So instead I use /timer 1 10 echo -a $time $eval($time,0) so that the contents of $eval is evaluated 0 times when the command is typed in, but then because of the way /timer works it is evaluated again when the timer executes after 10 seconds so that it gives the correct time.

These are very simple examples but hopefully you see my point that $eval() is a very useful identifier.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Dec 2002
Posts: 271
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 271
another good example, sometimes you may find you are trying to send data to and alias, or echo, or message room, and it may contain a work that starts with %watever thats you dont want to be treated as a variable....

//privmsg $chan %a is a variable

will message the room either, [the value of %a] is a variable, or: is a variable(if %a doesnt exist) and this happens because it tryied to evaluate %a, so if you think logically, $eval(%a,0) would message the room: %a is a variable, since we arent evaluating the %a wink

or, if you have a nested variable, for example, we have this in our variables section:

%a %nested
%nested this is what you get

if you do // echo -a %a

you will get: %nested

bu if you do //echo -a $eval(%a,2)

you will get: this is what you get

wink

Joined: Feb 2003
Posts: 282
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
thanks smile

Joined: Feb 2003
Posts: 83
L
Babel fish
Offline
Babel fish
L
Joined: Feb 2003
Posts: 83
Hmmm, Wunder, Could i of used this when i was writing my f-serv...


When i wrote the sendfail remote, $send(#).status would still read active, maybe by using the $eval it wouldnt of ?

Sumthin like $eval( $send(#).status ) , 2) ?


any help would make me happy

Link Copied to Clipboard