Math::Script NSIS plugin.

Another huge, undocumented, bug-full, but "might be useful" plugin.

C-like style scripting (operators at least).
Tip1: plugin watches the case of the letters.
Tip2: plugin makes almost no error checks. So YOU should check your script
twice before run :)

New HOW TO USE: run the MathTest.Exe, and try yourself. After spending 
some minutes your should be able to write your script by yourself.
To include it to your NSIS script just insert that (don't forget /NOUNLOAD
in case of multiple calls): 
        Math::Script /NOUNLOAD "YourScript1"
        Math::Script /NOUNLOAD "YourScript2"
        Math::Script "YourScriptFinal"

How to use it? Simple:
        Strcpy $0 "Brainsucker"
        Math::Script "a = 'Math'; B = 'Script'; r0 += ' wants to use ' + a + '::' + b +'!'"
        DetailPrint "$0"
That string will fill r0 with some shit. 

Here are some other samples:
        10! (factorial, r0 will contain '10! = 362880'):
                r0 = '10! = ' + (1*2*3*4*5*6*7*8*9)
        the same:
                a = b = 1; {++a <= 10, b = b*a}; r0 = (a-1) + '! = ' + b
        Some floating point:
                Strcpy $R0 "1e1"
                Math::Script "pi = 3.14159; R1 = 2*pi*R0; r0 = 'Length of circle with radius ' + R0 + ' is equal to ' + R1 + '.'"
                Detailprint "$0"        

Ok. Variables. 
NSIS: r0-r9 -> $0-$9. R0-R9 -> $R0-$R9. 
Also CL ($CMDLINE), ID ($INSTDIR), OD ($OUTDIR), LG ($LANG), ED ($EXEDIR).
User definable: name starting from character, up to 28 letters long.

Supported types: int (in fact that is __int64), float (double in fact),
string.
Int: just numbers, may include sign.
Float: -123.456, 123.456e-78, 123e-45
String: something in quotes ("", '', ``).

Operators (some binary, some unary):
>>= <<= -= += /= *= |= &= ^= %= -- ++ >> << && || <= =< >= => != ==
-> <- = + - * / % < > & | ^ ~ !
Only some are applicable to float (logic & arithmetic) and string (+ and logic) 
of course.

Script is set of expressions (mathematical in general) delimeted with ';'.
Processing is not mathematicaly right (2+2*2 will give 8, not 6), so use round
brakes (for ex: 2+(2*2) ).

Flow control:
        if-then-else like:      [if-expression, then-expr, else-expr]
                example:
                        [a==0, b=1; c=2, b *= (--c); c/=10]               
                C eq:
                        if (a==0) { b=1; c=2;} else { b*=(c++);c-=10; }
        while (expr) do; like    {expr, do}
                example:
                        {(c<1.1e25)&&(b < 10), b++; c*=1.23}
                C eq:
                        while ((c<1.1e25)&&(b<10)) { b++; c*=1.23; }

WATCH OUT! Comma (,) separates if-expr, then-expr, and else-expr from each 
other. All sub-expressions separated by (;) are the part of one expression,
and the result of the last one of these sub-exprs gives you the result of 
expression.

All the shit (like variables) will be saved between calls if you'll use
/NOUNLOAD or setpluginunload alwaysoff.

Functions:
        type conversions:
                s(source)       converts source to string type
                i(source)       converts source to int type
                f(source)       converts source to float type
                ff(float, format)       converts float to string, with format
                                        options.
                        options = precision + flags.
                        Precision shows how many digits after decimal point
                        will be shown. Flags:
                                16 (or 0x10) - No Exponential View 
                                        (number will be shown as 123.123)
                                32 (or 0x20) - Only exponential view
                                        (number will be shown as 123.12e123)
                                64 (or 0x40) - use 'E' character instead of 'e' 
                        By default the plugin decides itself how to show your
                        number.
                len(string)     returns the length of string argument
        math (description of all these functions is available at MSDN):
                sin(x), cos(x), ceil(x), cosh(x), exp(x), abs(x), floor(x),
                asin(x), acos(x), atan(x), log(x), log10(x), sinh(x), sqrt(x),
                tan(x), tanh(x)

                functions which may require explanation:
                        atan2(x, y) - Arctan of the value (y/x)
                        pow(x, y)   - power, x^y
                        fmod(x, y) - floating point remainder
                        frexp(x, o) - Gets the mantissa (result = r) 
                                and exponent (o) of floating-point number (x)
                                x = r*(2^o)
                        modf(x, o) - Splits a floating-point value into 
                                fractional and integer parts.

(c) Nik Medved (brainsucker)