$eval

From Scriptwiki
Jump to: navigation, search

Returns the string N times evaluated.

 $eval(string,N)

If N isn't specified, N is set to 1.

Examples

var %var = m00
var %string = % $+ var

Now echoing %var would echo "m00" and echoing %string would echo "%var"

echo -a $eval(%string,0) returns %string

This would echo "%string" since %string is not evaluated.

echo -a $eval(%string,1) returns %var

This would echo "%var" since %string is evaluated once. Notice that this is the same as echoing %string

echo -a $eval(%string,2) returns m00

This would echo "m00" since the string is first evaluated to %var and %var is then evaluated to m00

$eval() is usually used with $+() to create dynamic varibles, here is an example:

Varibles set:
%show.1 Information for the public!
%show.2 Private information!
%show.3 Example data.

on *:text:!show &:#mychan: {
  ;If $2 is not a number or its not 1 or greater, return the synopsis.
  if ($2 !isnum 1-) msg $chan Synopsis: !show <number>
  ;First use $+() to create the text %show.$2 where $2 is the number you typed after !show, for example 1.
  ;So its %show.1 you then need to make sure you need to re-evaluated it again, to get the value.
  ;thus should return: Information for the public!
  else msg $chan Info: $eval($+(%,show.,$2),2)
}

!show 1
<Bot> Info: Information for the public!
!show 0
<Bot> Synopsis: !show <number>
!show 3
<Bot> Info: Example data.

Note

$() is an alias of $eval() but is also used in text matches, for example in on text.

See Also