# Variables in texts, ID numbers

Texts are used in particular for dimensions, texts, and labels. In all of these locations, the text or parts of it can be entered directly or defined via variables.

* An arbitrary number of text fragments can be mixed with variables in texts. For example:\
  \&#xNAN;**'Length: #VL\[m,3]#, Width: #VB\[cm,1]#, Height: #VH\[cm,1]#'**
* Texts can be queried via variables with the unit '**txt**' or enumerations (**Enum**).

> - Variables with ID numbers or bar types can also be used directly.
> - In addition, all numbers from variables or intermediate values can also be used with the corresponding formatting.
> - It is also possible to output values from the system variables available in the current situation.

* Numeric values that are to be used in texts or labels can be provided with a format.

> - To do this, the unit and the number of decimal places are appended to the variable in square brackets. Example: **#V23\[cm, 1]#** for the variable 'V23' in centimeters with one decimal place.
> - For the units m (meter), cm (centimeter), mm (millimeter), and in (inch), the number of decimal places is specified. For the unit ft (feet-inch), the so-called 'fraction' is specified, for example '16' for one-sixteenth inch.
> - For angle specifications, the degree symbol is to be used as the unit, for example **#VAngle\[°,1]#**.
> - For numeric values that do not represent lengths or angles, the unit can be omitted. However, the comma before the number of decimal places must still be written, for example **#VCount\[,1]#**.; Example for 'no decimal places': **#VCount\[,0]#**.
> - (V20.02) For outputting variables in texts, there is an additional formatting option. After the decimal places, a fill character and the total number of characters are appended.
>
> Example variable **V\_Number=34.34676**. The formatting **#V\_Number\[m,2]#** outputs in m with rounding to 2 decimal places: **34.35**. Now the formatting can be extended to **#V\_Number\[m,2,x,8]#**; this pads the text at the beginning with x to a total of 8 characters: **xxx34.35**. The decimal separator is also counted as one character.
>
> If no fill characters are required, the formatting can still be written with unit and decimal places: **#V\_Number\[m,2]#**.
>
> If a text variable is formatted in length, no unit or rounding is required. For the variable **V\_Text=abcde** the formatting **#V\_Text\[,,-,8]#** pads the text at the beginning with - to a total of 8 characters: **---abcde**. In the formatting, the first two commas must be specified even if no unit or rounding is given there.
>
> This formatting is used, for example, for right-aligned lists or for generating file names.

The variables can also be used in the same way for ID numbers. This means that the ID number to be transferred to components or library elements can be assembled from text fragments. In this way, an dimension can be incorporated into the ID number, for example. Example: An ID number is to be composed of the text '**Pipe**' and the length from **VL** in mm without decimal places. The expression for the ID number is then: **Pipe#VL\[mm,0]#**.

Texts can also be assembled in intermediate values of composite elements. The conditional intermediate values are of particular importance here, because this allows a text to be assembled differently for different conditions. See also the chapter 'Composite elements - intermediate values'.

### Special rules in formulas for intermediate values of type text

If an intermediate value has the type text (unit **txt**), then plain text, all types of variables, or a mixture of both can be assigned directly, i.e. written into the formula. The following rules must be observed:

> * If the intermediate value is to directly take the value of a variable of type text, then this variable can be written directly into the formula without special characters. So if the intermediate value **V\_ZW\_Text1** is to receive the value of the variable **V\_Var\_Text** , the formula is simply: **V\_Var\_Text**
>
> Attention: The program first checks whether the entire text of the formula matches the name of a variable (system variables, user variables, intermediate values). If this is the case, the text is preferentially interpreted as a variable and its value is adopted.
>
> So in our case, the text **V\_Var\_Text** cannot be assigned directly; it would be replaced by the contents of the variable. The same applies to system variables: if a formula consists only of the word **SWAKT**, this word is always replaced by the contents of the system variable **SWAKT** (current floor).
>
> If the text is required to consist only of the name of a variable (system variables, user variables, intermediate values), then a character must be prefixed or appended. A space may also be placed in front. Operators (-+\*/\~<>= etc.) are not permitted here. For our examples, the following would be possible, for example: **\_SWAKT** or **SWAKT\_**.
>
> * If variables (system variables, user variables, intermediate values) are combined with plain text, the variable names must be enclosed in # : **Plain text #SWAKT#**
> * (17.01) These rules also apply to formulas that are part of a conditional formula.\
>   (18.01) Note that plain text in conditional formulas must always be written in quotation marks.\
>   Example: The value of **SWAKT** be **GF**.
>
> The conditional formula **(*****Condition*****);(#SWAKT#);(SWAKT)** produces the following result:
>
> Condition met: **GF** (#SWAKT# is replaced by value)
>
> Condition not met: **GF** (SWAKT is recognized as a variable; since it stands alone, it is also replaced by value)
>
> The conditional formula **(*****Condition*****);("Plain text" #SWAKT#);("Plain text" SWAKT)** produces the following result:
>
> Condition met: **Plain text GF** (#SWAKT# is replaced by value)
>
> Condition not met: **Plain text SWAKT** (SWAKT is not recognized as a variable because it does not stand alone)

#### Conditional formulas for intermediate values of type text (unit txt)

(21.01) For intermediate values of type decimal number (unit m), conditions may contain both mathematical formulas and text comparisons. However, the formulas of intermediate values of type text (unit **txt**) are treated entirely as text; conditions are therefore evaluated using text comparison. Conditions for intermediate values of type text must not contain mathematical formulas.

> Example of an intermediate value of type text:
>
> The following conditional formula is possible because the condition compares text: The name of the execution variant must contain **AW** , then **C24** is used, otherwise **KVH-Si**:
>
> Possible formula: **(AUSF={AW\*});(C24);(KVH-Si)**
>
> The following conditional formula is not possible because the condition contains mathematical formulas. The program would recognize the variable **V\_Width** and compare its value with the text "**2.0**" after alphabetical sorting: And this gives confusing results:
>
> Incorrect formula: **(V\_Width>2.0));(C24);(KVH-Si)**
>
> Attention! If **V\_Width** has the value **3.00** , then the texts "**3.00**" and "**2.00**" would be compared and the result **C24** looks correct. This is because 3 comes alphabetically after 2 and is therefore larger. If **V\_Width** however has the value **10.00**, then the result is **KVH-Si**. The "**10.00**" is therefore not greater than "**2.00**", because 1 comes before 2 in the alphabet and is therefore smaller.

**\[Note:]** Since the content for an intermediate value can also be a conditional formula, this is checked first. If a comparison sign (=, <, >, !=) is found, the system assumes a conditional formula and attempts to parse accordingly from that sign onward. Conversely, this means that a simple text may not contain such a sign. The text entry **Length=1.00** (with or without quotation marks) would therefore not be accepted, because the system would interpret it as a conditional formula and run into an error.

**\[Recommendation for conditions for intermediate values of type text (unit txt):]**

If you want to condition intermediate values of type text (unit txt) with mathematical formulas, you must enter them in the variable condition field. Then the conditions are not part of a conditional formula, but independent conditions and are analyzed accordingly. Both mathematical formulas and text comparisons are then possible here.
