help/en/hlp_eval.txt
author Myhailo Danylenko <isbear@ukrpost.net>
Fri, 15 Jan 2010 15:44:00 +0200
changeset 4 faaed3ae3fa8
parent 1 320e4393785a
permissions -rw-r--r--
String head and tail operators * : string head * ^ string tail * fix for negative integer detection


 /EVAL [expression]

Evaluates expression and executes result string as command.
Expression evaluation rules:
* all operators have the same precedence;
* supported operators:
  . string concatenation
  : string head
  ^ string tail
  + binary plus / string concatenation
  - binary minus
  * multiplication / string replication
  / division
  % division remain
  < binary / string less than
  > binary / string greater than
  = binary / string equality
* strings must be quoted with double quotes ("..."), within string backslash is used for character escaping (\\ and \" are only useful applications);
* parentheses can be used to change operators precedence, nested parentheses are supported as long as they are balanced;
* numbers can be specified as plain decimal numbers, minus in front of digit will be recognized as a part of number;
* mcabber variables can be specified by name, though only subset of possible names is suppoted:
  - variable must start from latin alphabetic symbol;
  - inside of variable name also are allowed digits, - and _;
* to enable parentheses in character strings current implementation ignores anything after extra closing paren - you may use this as a sort of comment...

Example:
 /eval "echo 2 + 2 = " . (2+2)
 /eval "set ping_interval = " . (ping_interval + 1)    ) this example probably should use /let command.
 /eval "echo " . (ssl_fingerprint : 5) . "..." . (ssl_fingerprint ^ 5)    ) negative offsets are also supported