To create a new calculation you can copy and modify an existing calculation. As an example we will examine how this source code will multiply two numbers for the user:Input
The Input list at the beginning of the source code creates the form to ask for the things we need from the user before we do the calculation. Heading puts a title above the form so the user understands the subject of the calculation. NumberIn displays a box where they can type a number. CalcButton shows a button labelled with some text to say what will be calculated when they press the button. Notice that NumberIn puts the number the user types in the box into the variable. In this example the variables are named n and p. We can use these variables in the calculation.
When the user clicks the CalcButton the calculation will happen and the Output will be displayed. In this example we multiply the two variables to get the total price. The total price is put in a new variable named t. The variables can be given longer names like total, price and oranges if this makes the calculation easier to understand. The calculation can have several steps if necessary. The operators available are the usual ones like * for multiply, / to divide, + to add, - to subtract and ^ to raise to a power. You can use brackets ( and ) to make it clear which parts of the calculation go together.
After the calculation has completed the Output will be displayed for the user. There is Heading for the title and LineOut which displays the numbers calculated.
|-||subtract and negative|
These operators return TRUE = 1 or FALSE = 0.
|>=||greater than or equal|
|<=||less than or equal|
Operators at the top of this list, with higher precedence, are calculated first. For example the expression 2 + 3 * 4 is the same as 2 + (3 * 4) . Brackets can be used in expressions when a different order is required.
|* /||multiply and divide|
|+ -||add and subtract|
|= > < >= <= <>||comparison|
|IF (logical, number, number)||Returns the first number if true and the second if false.|
|AND (logical, logical)|
|OR (logical, logical)|
|LN (number)||Natural logarithm. Log to the base e.|
|LOG (number, base)||Logarithm to the specified base.|
|LOG10 (number)||Logarithm to base 10.|
|EXP (number)||e raised to the power of the given number.|
|POWER (number, power)||Number raised to the power. Equivalent to number ^ power.|
|SQRT (number)||Square root of the number.|
|COS (number)||Cosine of the angle which is in radians.|
|SIN (number)||Sine of the angle which is in radians.|
|TAN (number)||Tangent of the angle which is in radians.|
|ACOS (number)||Arccosine of the number. Returned in radians.|
|ASIN (number)||Arcsine of the number. Retured in radians.|
|ATAN (number)||Arctangent of the number. Returned in radians.|
|DEGREES (number)||Converts the angle in radians to degrees.|
|RADIANS (number)||Converts the angle in degrees to radians.|
|ROUND (number)||Rounds the number to the nearest integer.|
|MROUND (number, multiple)||Rounds the number to the nearest multiple of the given number. e.g. MROUND(3.16, 0.1) gives 3.2|
|FLOOR (number, multiple)||Rounds towards zero to the next multiple of the given number. e.g. FLOOR(3.116, 0.01) gives 3.11|
|CEILING (number, multiple)||Rounds away from zero to the next multiple of the given number. e.g. CEILING(2.3, 2) gives 4|
|ABS (number)||Returns a positive version of the number. Absolute.|
|MOD (number, number)||Returns the remainder after dividing the first number by the second.|
|RAND ()||Returns a random number which can be zero or any number above zero but less than 1.|
|RANDBETWEEN (bottom, top)||Given the values of the smallest and largest integers it is allowed to produce. Returns a random integer in this range.|
|MIN (number, number)||Returns the smallest number.|
|MAX (number, number)||Returns the largest number.|
A more elaborate calculation example:Input