# Intermediate Values

For composite elements, the intermediate values system is available. Intermediate values are variables whose value is calculated by a formula. The main purpose is to break formulas down into several steps so that they can be calculated more clearly. In addition, the result can be used in any number of other places; there it is not necessary to include the complete formula at every location.

* Intermediate values can be used in formulas like variables. They also begin with 'V' and must be unique within a composite element together with the variables.
* Intermediate values are variables whose value is calculated from variables or other information. The value of an intermediate value can be used in subsequent intermediate values.
* Intermediate values can be documented like variables by means of a description and auxiliary images. This documentation is important for the developer of the composite element.
* Intermediate values can be saved and managed as variable sets.
* Possible units for intermediate values are m and txt. However, 'm' is not to be understood here as meter, but stands for any number with or without decimal places. Intermediate values are assigned the unit 'm' by default; in the 'Variable definition' dialog, this can be changed to 'txt'.
  * Intermediate values with the unit 'm' can be calculated using the usual mathematical formulas.
  * Intermediate values with the unit 'txt' are texts. Here, the formula composes a text with all entries and formatting according to chapter 'Variables in texts, ID numbers'. The formula editor is not used here.
* A condition can be defined for each intermediate value. If the condition is met, the intermediate value receives the value of the formula. If the condition is not met, the intermediate value receives the value 0.0 for unit 'm' or an empty text (not even a space) for unit 'txt'.

Examples:

* Several library elements have the same calculated values, e.g. lengths. Without intermediate values, the complete formula would have to be included in each library element. Now the length is calculated once as an intermediate value, and only the intermediate value is entered in the library elements. If the formula of the intermediate value is corrected, all affected library elements are corrected as well.
* A calculated angle must be used in several formulas. Without intermediate values, the calculation of the angle would have to be inserted into every formula. Now the angle is calculated only once as an intermediate value and this intermediate value is inserted into the further formulas.

### Intermediate Values Export - Import, Editing with Editor

(from version 13.01) Intermediate values can become very extensive. Editing in the dialog then becomes time-consuming and confusing. There is the option to export the intermediate values to a file, edit the file with an editor, and finally import it again.

* With export, all intermediate values are written line by line to the file **%dhptmp%\ZWEditor.txt** written.
* The file **%dhptmp%\ZWEditor.txt** is edited with an editor (e.g. Notepad). Set the tab stop size to, for example, 40. The usual functions for editing, copying, searching, and replacing can then be used. The overview is better because all intermediate values, conditions, and formulas are visible at the same time.
* The file is saved and imported again in the dialog. First all existing intermediate values are deleted; only the content of the file remains available afterwards.
* The file **%dhptmp%\ZWEditor.txt**:
* In the file, each intermediate value is on one line.
* The data are separated by tab stops; the character encoding is UTF-8 (pay particular attention when editing with Excel!).
* The data fields in one line are:

> **1. Variable name** Name of the intermediate value
>
> **2. Variable prompt** Comment for the description of the intermediate value
>
> **3. Variable condition** Condition
>
> **4. Formula** Formula
>
> **5. Unit** Unit: **meter** or **text**.
>
> **6. Variable description** detailed description
>
> **7. Auxiliary image** Image for explanation
>
> **8. Variable group** Group
>
> **9. Fixed value** not relevant here, always 0
>
> **10. External** not relevant here, always 0
>
> **11. Variable display** not relevant here, always empty
>
> **12. Enum list** not relevant here, always empty
>
> * Each line must contain all data fields, i.e. sufficient tab stops, even if they are empty.

### Conditional intermediate values

Conditional intermediate values with numeric values:

This is an important technique for performing different calculations depending on conditions.

* A condition can be defined for each intermediate value. If the condition is met, the intermediate value receives the value of the formula. If the condition is not met, the intermediate value receives the value 0.0.
* Multiple conditions can also be linked with &. So if VAB must be greater than 4 and less than 8, the full expression is: **(VAB>4)&(VAB<8)**
* First, an intermediate value is calculated for each condition. These are, for example, **VBZ1, VBZ2,** etc. If the condition is met, the intermediate value receives the calculated value; otherwise it is 0.
* The intermediate value actually required is finally calculated as the sum of the conditional intermediate values: **VBZ = VBZ1 + VBZ2 +.**.. Since the invalid **VBZ? = 0** are, only the valid value is passed to **VBZ** .
* **VBZ** is now used at the desired locations, e.g. in a library element. Without conditional intermediate values, a library element with corresponding conditions would have had to be created for each situation.

Conditional intermediate values with texts:

In this way, texts can also be composed that must differ depending on the condition. These texts can also be used for ID numbers. Without this approach, a different insertion of a component, library element, or text would have to be created for each different text.

* A condition can be defined for each intermediate value. If the condition is met, the intermediate value receives the composed text. If the condition is not met, the intermediate value receives an empty text (not even a space).
* Multiple conditions can also be linked with &. So if VAB must be greater than 4 and less than 8, the full expression is: **(VAB>4)&(VAB<8)**
* First, a text is created for each condition. These are, for example, **VBT1, VBT2,** etc. If the condition is met, the intermediate value receives the created text; otherwise it is empty.
* The intermediate value actually required is finally composed from the conditional intermediate values: **VBT = #VBT1##VBT2#..**. Since the invalid **VBT?** are empty, only the valid text is passed to **VBT** .
* **VBT** is now used at the desired locations, e.g. in a label or as an ID number in a library element. Without conditional intermediate values, a label or a library element with corresponding conditions would have had to be created for each situation.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.dietrichs.com/dietrichs-intelligent-documentation/docs-de-en/combined-elements/create-edit-combined-elements/intermediate-values.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
