Test controller, calculator

Calc1

This calculator has a very simple window, but can do a lot of math. The expression must be typed in, the advantage with this is that they can be modified or corrected easily and the expression is saved on a list and can be reused.


Contents
    Numeric display format
    Input line
    Output
    Input number and text format
    Operators
    Variables
    Scripting
Functions
Main page



Numeric display format

format

The calculator can display in multiple formats: Formats will fall back to Str format for values they cannot handle (Like text).



Input line

input

All expressions is written on the input line and calculated when "ENTER" is pressed. If the field gets red there is something wrong with the expression.
All successful expressions are saved and can be found by clicking the black triangle.




Output

output

Output is shown on the line above the input line.

input2
input2a

A more a advanced function may have more advanced output, here I show two different format options.

menu

Right clicking opens a menu where the output can be copied to the clipboard or copied to the main log window in TestController.



Input number and text format

The numeric input in the calculator is very flexible in handling different formats: There are two caveats in the input format: As can be seen above both i & j can be used for complex notation. The last letter used is remembered and used when showing complex numbers.

Using "text" will create a text string. String supports a couple of escape codes: \" \\ \r \n \t \b \xXX \uXXXX
The X must be replace with hex digits.
A text string containing a number will automatic be converted to a number if needed. This means "123"+1 is legal and will return 124
The conversion of text strings to numbers is simpler than above and do not support any SI prefixes



Operators

The operators mostly matches C and Java operators. The operators are: For operators requiring a specific data type the value is converted to that type (if possible).

Before a number it is possible to use one of:


Variables

It is possible to create variables and use them in expressions.
Code:
VAR name
GLOBALVAR name
VAR name = value
GLOBALVAR name = value

The GLOBAL version will make the variable available anywhere in TestController where an expression can be used, the plain VAR version is only accessible in the calculator.
One way to use VAR is when the same value is used multiple times:

var f=10k;cpxToCLRs(f,par(cpxC(f,3u),cpxL(f,50u),cpxR(100)))

input3

In the above expression I can easily change the f value and redo the calculation.



Scripting

This popup can be controlled with:

#SHOWPOPUPSYSTEM Calculator {x y {w h}}
#CLOSEALL

Any scripting line starting with a equal sign = is passed to a instance of the calculator engine. This means GLOBALVAR is shared between them, but not VAR. Anything within parentheses on a scripting line is also handled by an instance of the calculator.