Expression evaluation identifier

Expression evaluation identifier
Usage
$(<expression>)
Description
Evaluates <expression> and returns its result.
If <expression> is a single string, array or hash, it is returned unmodified.
In any other case the expression evaluation returns a numeric value, either real or integer.
The expressions are really close to the C ones and have some minor extensions.
The supported operators are +,-,*,/,|,&,^,||,&&,^^,>>,<<,<,>,<=,>=,==,!= and <> (synonim for !=).
The following table describes their meaning.
                                                                                                   
OperatorDescription
a + bArithmetic sum: valid only for numeric operands
a - bArithmetic subtraction: valid only for numeric operands
a / bArithmetic division: valid only for numeric operands
a * bArithmetic multiplication: valid only for numeric operands
a % bArithmetic modulus: valid only for numeric operands
a || bLogical or: valid only for boolean operands
a && bLogical and: valid only for boolean operands
a ^^ bLogical xor: valid only for boolean operands
a >> bBitwise shift right: valid only for integer operands
a << bBitwise shift left: valid only for integer operands
a | bBitwise or: valid only for integer operands
a & bBitwise and: valid only for integer operands
a ^ bBitwise xor: valid only for integer operands
a > bGreater than: valid for numeric or string operands. Case sensitive
a < bLower than: valid for numeric or string operands. Case sensitive
a >= bGreater or equal to: valid for numeric or string operands. Case sensitive
a <= bLower or equal to: valid for numeric or string operands. Case sensitive
a != bNot equal to: valid for numeric or string operands. Case sensitive
a == bEqual to: valid for numeric or string operands. Case sensitive
The expressions can contain integer, real or string constants and variable operands.
The integer constants can be also specified as hexadecimal numbers by prefixing them by '0x'.
The string constants should be enclosed in quotes.
Syntax Specification
$(<expression>)
Examples

    echo $(10 + 5 * 100)
    echo $(10 / 3)
    echo $(10 / 3.0)
    echo $(10.0 + 5 * 100)
    echo $(145 & 2)
    echo $("hello" > "ciao")
    echo $(10 == "10")
    %a = 100
    %b = 50.3
    %c = "test"
    echo $(%a + %b)
    echo $("%a%b" + 1)
    echo $(%a + %b > %c)
    echo $(-(10 + 20) * 3)
    echo $(1 ^ 2)
    echo $(1 ^ 1)
    echo $(0xffff == 65535)
    ...


Index, Language Overview
KVIrc 3.9.99 Documentation
Generated by root at Wed Oct 17 19:34:06 2007