Module «Calculation»

The «Calculation» module is a connecting module or a module for pre- and post-processing data from other modules. This module is necessary for creating, calculating and changing values of variables.

Module interface

The module window is really simple and consists only of an entry field and the «Save» and «Cancel» buttons.

![Screenshot](img/calculation_1.png)

The «Expression» field. The operations that need to be done with variables are entered into this field. This can be addition, subtraction, multiplication or function calculation.

Supported operations

● + (addition);

● - (subtraction);

● * (multiplication);

● / (devision);

● % (remainder of the division);

● \ (integer from division);

● ^ (exponentiation).

All lines should look like this «Variable = Operation;», operation can consist of a single number or a line, as well as several operands connected by the operators specified above, or it can be a function.

Each line should be separated by the «;» symbol. ## Example of working with the module

Suppose you want to get the last day of the previous month. You can do this by entering the following code:

![Screenshot](img/calculation_2.png)

![Screenshot](img/calculation_3.png)

What are we doing here? Here, we're getting today's date, for example, today is 25th of march, subtract one day more from today’s date than it actually is, meaning that, 26 days and end up in the last day of the previous month - February 29 (if the year is a leap year). In more details:

1st line – Using GetDate function which returns today's date and saves its result in a variable @now (@now = 25.03.2020);

2nd line - the use of the GetDay function, which takes one parameter - the date, and returns only the day from the date supplied to it. Let's set today's parameter as the parameter, which lies in the @now variable. We enter the result of the function to the variable @day (@day = 25);

3rd line – increasing the @day variable by one (@day = 26);

4th line – using the DateAdd function, which takes three parameters: the first parameter - «day», «month» or «year» - is the component of the date that we are working with, the second parameter is the amount that is added to the selected component of the date, and the third parameter is the date with which the manipulation is performeed. Subtract 26 days from today's date - use DateAdd with parameters:

1. day – subtracting date ;

2. –@day – we add the minus because the function adds by default

3. @now – today's date.

In result, we subtract 26 days from 25.03.2020 and end up on 29.02.2020.