The Bridge supports the following basic arithmetic operations: multiplication, division, subtraction, and addition.
It is allowed to put expressions into parentheses, e.g. 3*(4+2)
instead of 3*4 + 3*2
.
Arithmetic expressions may be defined in the scripts section of action nodes. The first line in the example below creates the output object result
. This is required before the attributes can be set. The following lines show examples of referencing the input values in mathematical operations.
Figure: Arithmetic Operations
If you provide the value 1 for numbers.integer2
, the value of result.Integer2
will be 2
(2.66
will be cut after the decimal point) because the result value is of type integer whereas the value of result.float1
will be 2.66
.
The variables and literals involved in an arithmetic expression must all be of the same type. This means you may not mix integers and floats. The expression |
Besides doing arithmetic with numbers it is also possible to do DateTime arithmetic. It is allowed to add/subtract durations to/from a given DateTime object. The UML example above shows how to add one month to a given DateTime object:
set resultDateTime = dateTime + convertDurationToDateTime("P1M"); |
This is calculated e.g. as follows:
In fact, these objects are represented as DateTime types but they are actually durations. For the exact lexical definition of duration, refer to convertDurationToDateTime.
You can also use dedicated DateTime operations for these arithmetics (see DateTime Operations), e.g. add subtract:
create duration; set duration.months = 1; set resultDateTime = dateTime.add(duration); set resultDateTime = dateTime.subtract(duration); |
Be careful with the following:
|