Structure of a formula

<< Click to Display Table of Contents >>

Structure of a formula

Formulas may contain up to 255 characters. Results are limited to 100 characters.

You can construct formulas from the following components:

Fixed values

In its simplest form, a formula results from a fixed value, as in the following examples:

Text strings

Example: "Hello!"
A formula with this content always results in the string "Hello!
(A string is a series of characters – letters, numbers, or special characters.)
Strings may be up to 100 characters long.
Important: If you enter fixed strings directly into a formula (for example, "Hello!"), they must be enclosed within "quotation marks". Otherwise, TextMaker will try to interpret it as the name of a function or variable.

Numeric values

Example: 42.50
Of course, a fixed value can also be a numeric value as in a number. This formula always returns the number 42.5.

Date entries

Example: "20.04.18"
This formula represents the date 4/20/2018.
Format of dates:
When entering fixed dates in formulas, please note the following:
1. If you enter fixed dates in formulas, you must add "quotation marks" to them.
2. The day and month must always be specified with two digits. "20.04.18" would be correct, "20.4.18" wrong (month has one digit).
3. The year can be specified with either two or four digits. Thus, both "20.04.18" and "20.04.2018" are allowed.
4. If you enter a two-digit year between 0 and 29, TextMaker automatically prefixes "20...". For years between 30 and 99, TextMaker prefixes "19...". The date "01.01.29" is thus interpreted as 1.1.2029, and the date "01.01.30" as 1.1.1930.

Database fields, table cells and objects

You can also use the contents of database fields, table cells and objects in formulas.

For more information, see Table cells in calculations, Database fields in calculations, and Objects in calculations.

Calculations

A formula can contain different types of calculations.

Example: 6*5

This always returns the fixed value 30, and it is actually a fixed value and not a calculation.

Example: 5*NUMBER

In this formula, the fixed value 5 is multiplied by the NUMBER variable. If NUMBER is currently 10, the formula returns 50.

TextMaker also provides a number of computational functions. For detailed descriptions, see Computational functions. Here are some examples in advance:

Example: TODAY()

The function TODAY() returns the current date. On September 16, 2018, for example, it would return 09/16/18.

Example: MONTH(TODAY())

Here, one function is applied to another. The function TODAY() returns the current date. However, this result is immediately evaluated by the MONTH() function, which returns only the month of the date (as a number). On September 16, 2018, the formula would thus produce the value 9.

Example: INT(B/1000)

Here, the FUNCTION INT, which removes the decimal places of a value, is applied to the calculation B/1000. If B has the value 3752.70, the formula produces the value 3.

Thus, the argument for functions can be a different function, any calculation, a database field, a table cell and, of course, a combination of all of them.

Variables

The result of a formula can be assigned to a variable.

Tip: In the dialog box of the ribbon command Insert | Field dropdown_arrow | Calculation, all currently defined variables appear in the list Variable/field. You can insert any of the variables in the formula by double-clicking on them.

Example: PRICE=17.99

The "formula" here is only the constant value 17.99. The entry as a whole defines the variable PRICE and sets it to 17.99. Its value is valid from the position in the text at which you insert it to the end of the text – unless you assign another value to the PRICE variable further down in the text.

Note: Whenever you assign a value or a calculation to a variable, the result of the variable appears at the current position in the text. If you do not want this – for example, because you only want to perform an intermediate calculation whose result is not to be displayed – enable the option Hide result when entering the formula in the dialog box of the ribbon command Insert | Field dropdown_arrow | Calculation.

Example: MONTH=MONTH(TODAY())

Here, the month of today's date is calculated and shown. At the same time, the result is also saved in the MONTH variable.

Of course, such variables can also be used in other formulas.

Example: PRICE*1.19

This formula returns the current value of the PRICE variable multiplied by 1.19.