Variable Expressions
Variable expressions
Sometimes it is useful to do some simple maths on variables in REPORTER . Creating a script to do something this simple is tedious. If you use the variable type then REPORTER will evaluate this when required to produce the result. For example assume that you have 2 variables, FORCE and AREA and you want to calculate a stress. You can do this by:
- Make a new variable STRESS .
- Set the type to .
- Give the value %FORCE%/%AREA% (see Creating and editing variables for more details) by either typing directly or using the right mouse button and Inserting variables with the menu.
Then if you have some text in the report such as "The stress is %STRESS%" REPORTER will evaluate the stress as required.
The expression can contain +, -, / and * to do addition, subtraction, division and multiplication respectively and can use brackets to enforce which order the expression is evaluated in. The expression is actually evaluated as a JavaScript program so more complex expressions can be formed by using the standard JavaScipt functions (e.g. the Math class). e.g. the following are all valid expressions
- %FORCE%/%AREA%
- Math.sqrt(%X%*%X% + %Y%*%Y%)
- Math.min(%X%, %Y%) * Math.sin(Math.PI)