Evaluation of mathematical expressions in substitution strings

You can evaluate mathematical expressions to provide configurable substitution strings anywhere that normal substitution strings can be applied. The expression should take the form:

%eval{<expression>}

You can use the following in your expression:

Operators:

+ - * / ( )

Comparison:

== != <= >= <>

Constants:

pi

Functions:

sin( ) cos( ) tan( )

abs( )

abs(a) returns the absolute value of a

max(;)

max(a;b) returns the highest value ofa or b

min(;)

min(a;b) returns the lowest value of a or b

if(;;)

if(a;b;c) returns b if a is non-zero/true and c otherwise

Examples

%eval{1+2}

is replaced by 3

%eval{max(1.2;2.2)}

is replaced by 2.2

%eval{min(1.2;2.2)}

is replaced by 1.2

%eval{abs(-5.6)}

is replaced by 5.6

%eval{if(5>4;10;20}

is replaced by 10