Document the variable and formula language, all five dialects of it

There is no single %-variable language in QET: element labels, conductor
texts, the folio field, title block cells and cross-reference labels each
resolve a different set, and a variable that works in one is left as
literal text in another with no error. The folio field is the sharpest
case -- it understands %autonum, %id and %total and nothing else, so the
%f and %{...} people reach for there print verbatim on every folio.

Also records two things the code says that nothing else documents:

- %f and %F are not interchangeable. %f is the folio index; %F inserts
  the folio *field*, which defaults to "%id/%total" and so renders
  "3/12". It works only because %F is expanded before %id and %total in
  the same pass.
- AssignVariables::replaceVariable() is a hard-coded list, not a lookup
  over elementInfoKeys(). Three omissions are deliberate (formula, xref,
  exclude_from_bom) but machine_manufacturer_reference_auxiliary1..4 are
  simply missing: the fields exist and can be filled in, the plain
  machine_manufacturer_reference resolves, and the four auxiliary
  variants stay on the drawing as literal text.

EN/FR/DE.
ispyisail
2026-09-11 21:47:33 +12:00
parent 4854c314f0
commit 7ebdce88f4
5 changed files with 706 additions and 0 deletions
+2
@@ -20,6 +20,8 @@
**[The project database](project_database)** — the in-memory SQLite cache
**[Variables & formulas](variables)** — `%f`, `%{label}`, sequences
**[Elements XML](elements_XML)**
* [attribute](elements_definition_attribute)
* [uuid](elements_child_uuid)
+1
@@ -59,6 +59,7 @@ Beginnen Sie mit der deutschen Version dieses Wikis:
| License | ✅ | ✅ | ✅ |
| Linking elements | ✅ | ✅ | ✅ |
| Project database | ✅ | ✅ | ✅ |
| Variables & formulas | ✅ | ✅ | ✅ |
**Legend:** ✅ Translated | 📋 Planned | ❌ Not yet started
+236
@@ -0,0 +1,236 @@
# Variablen und Formeln
Mehrere Felder in QElectroTech nehmen eine **Formel** entgegen — Text mit
`%`-Variablen, die QET beim Zeichnen ersetzt. `%f-%l%c` auf einer
Elementbeschriftung wird zu `3-B7`. `%id/%total` im Foliofeld wird zu `3/12`.
Der Haken: Es gibt **keine einheitliche Variablensprache**. Fünf verschiedene
Stellen nehmen Formeln entgegen, jede löst einen anderen Satz auf, und eine
Variable, die an einer Stelle funktioniert, bleibt an einer anderen
stillschweigend als wörtlicher Text stehen. Dafür ist diese Seite da.
Quellen: `sources/autoNum/assignvariables.cpp` (`AssignVariables`,
`replaceVariable`), `sources/bordertitleblock.cpp`,
`sources/titleblocktemplate.cpp` (`interpreteVariables`).
---
## 1. Wo Formeln zulässig sind
| Ort | Eingestellt in | Löst auf |
|---|---|---|
| **Elementbeschriftung** | Elementinformationen oder Projekteigenschaften → Elementnummerierung | Position, Folio, Sequenzen, `%{…}` |
| **Leitertext** | Leitereigenschaften → Formel, oder Leiternummerierung | Position, Folio, Sequenzen, Drahteigenschaften |
| **Foliofeld** | Folioeigenschaften → *Folio* | **nur** `%autonum`, `%id`, `%total` |
| **Schriftfeldzellen** | die `.titleblock`-Vorlage | was im Schriftfeld-Kontext steht |
| **Querverweis-Beschriftungen** | Projekteigenschaften → Querverweise | wie Elementbeschriftungen |
---
## 2. Folio- und Positionsvariablen
Diese lösen auf Elementbeschriftungen, Leitertexten und
Querverweis-Beschriftungen auf.
| Variable | Wird zu |
|---|---|
| `%f` | **Index** des Folios, ab 1 |
| `%id` | derselbe Folio-Index — `%f` und `%id` sind hier identisch |
| `%F` | das Folio-**Feld**, also das, was die Einstellung *Folio* ergibt |
| `%total` | Gesamtzahl der Folios im Projekt |
| `%M` | Anlage (*plant*) des Folios |
| `%LM` | Ort / Maschine (*locmach*) des Folios |
| `%l` | der Zeilenbuchstabe der Elementposition im Rahmen |
| `%c` | die Spaltennummer der Elementposition |
| `%prefix` | das Präfix des Elements |
### `%f` und `%F` sind nicht austauschbar
`%f` ist der Folio-Index — eine bloße Zahl. `%F` fügt das Folio-*Feld* ein, das
selbst eine Formel ist. QETs Vorgabe für dieses Feld lautet `%id/%total`, also
auf Folio 3 von 12:
```
%f → 3
%F → 3/12
```
Beides liest sich in einer Beschriftung natürlich, weshalb der Unterschied
unbemerkt bleibt — bis jemand das Foliofeld ändert und alle
Elementbeschriftungen ihre Form mitändern. Wer die Zahl will, nimmt `%f`.
### `%c` zählt je nach Einstellung ab 0 oder ab 1
Die Spaltennummer fällt um eins kleiner aus, wenn die Einstellung *Spalten
beginnen bei 0* aktiv ist. Dasselbe Projekt, von zwei Personen mit
unterschiedlichen Einstellungen geöffnet, ergibt unterschiedliche
Beschriftungen. Sollen Beschriftungen im Team stabil sein, einigen Sie sich
zuerst darauf.
---
## 3. Leitervariablen
Nur in Leiterformeln:
| Variable | Wird zu |
|---|---|
| `%wf` | Funktion des Leiters |
| `%wv` | Spannung / Protokoll |
| `%wc` | Drahtfarbe |
| `%ws` | Drahtquerschnitt |
---
## 4. Sequenzvariablen
Die automatische Nummerierung stellt nummerierte Sequenzen bereit. Jede gibt es
projekt- und folioweise, und jede nimmt einen angehängten Index — `_1` ist die
erste im Nummerierungsschema definierte Sequenz, `_2` die zweite und so fort.
| Familie | Pro Projekt | Pro Folio |
|---|---|---|
| Einer | `%sequ_1` | `%sequf_1` |
| Zehner | `%seqt_1` | `%seqtf_1` |
| Hunderter | `%seqh_1` | `%seqhf_1` |
| Alphabetisch | `%seqa_1` | — |
| Umlauf | `%seqw_1` | — |
Eine Sequenzvariable, deren Index im aktuellen Schema nicht existiert, bleibt
**unverändert im Text stehen**. Ein wörtliches `%sequ_2` auf einem Folio heißt,
dass das Schema nur eine Sequenz definiert — nicht, dass die Nummerierung
fehlgeschlagen ist.
---
## 5. Elementinformations-Variablen — `%{…}`
Variablen in geschweiften Klammern greifen auf die Informationsfelder des
Elements zu:
```
%{label} %{manufacturer_reference}
```
Gebräuchlich: `%{label}`, `%{plant}`, `%{location}`, `%{function}`,
`%{comment}`, `%{description}`, `%{designation}`, `%{manufacturer}`,
`%{manufacturer_reference}`, `%{machine_manufacturer_reference}`,
`%{supplier}`, `%{quantity}`, `%{unity}`.
Ebenfalls verfügbar: `%{auxiliary1}``%{auxiliary4}` samt ihren Varianten
`description_`, `designation_`, `manufacturer_`, `manufacturer_reference_`,
`supplier_`, `quantity_` und `unity_`; die SPS-Felder `%{plc_type}`,
`%{plc_address}`, `%{plc_function}`, `%{plc_comment}`, `%{plc_crossref}`,
`%{plc_t1}``%{plc_t4}`, `%{plc_tc}`; die Leiterfelder
`%{conductor_color}`, `%{conductor_section}`, `%{tension_protocol}`; und
`%{void}`, das sich zu nichts auflöst.
### Die Liste ist fest verdrahtet, und vier Felder fehlen darin
Die `%{…}`-Ersetzung ist eine feste Liste in
`AssignVariables::replaceVariable()`, kein Nachschlagen über alle
Informationsfelder. Ein Element trägt **57** Informationsschlüssel; **59**
geschweifte Variablen werden erkannt, und beide Mengen decken sich nicht
vollständig.
Drei Schlüssel fehlen absichtlich — `formula` (das *ist* die Formel), `xref`
und `exclude_from_bom` (ein Schalter, kein Text). Vier weitere fehlen jedoch
ohne erkennbaren Grund:
```
%{machine_manufacturer_reference_auxiliary1}
%{machine_manufacturer_reference_auxiliary2}
%{machine_manufacturer_reference_auxiliary3}
%{machine_manufacturer_reference_auxiliary4}
```
Sie können diese Felder an einem Element ausfüllen, und das einfache
`%{machine_manufacturer_reference}` löst normal auf — die vier
Zusatz-Varianten stehen aber nicht in der Ersetzungsliste und bleiben daher als
wörtlicher Text auf der Zeichnung. Wer eine Maschinen-Herstellerreferenz für
ein Zubehörteil braucht, nutzt bis zur Behebung ein anderes Feld.
---
## 6. Variablen des Foliofelds
Das Foliofeld ist die Ausnahme auf dieser Seite: Es wird von einer anderen
Funktion aufgelöst und kennt **nur drei Variablen**.
| Variable | Wird zu |
|---|---|
| `%id` | der Index dieses Folios |
| `%total` | die Anzahl der Folios |
| `%autonum` | der Wert der automatischen Folionummerierung |
Die Vorgabe ist `%id/%total`. **`%f`, `%l`, `%c`, `%M`, `%LM` und `%{…}` tun
hier nichts** — sie bleiben wörtlich im Feld stehen und werden auf jedem Folio
genau so gedruckt, wie sie eingegeben wurden. Das ist die häufigste
Variablen-Enttäuschung in QET.
---
## 7. Schriftfeld-Variablen
Zellen von Schriftfeldvorlagen nutzen einen eigenen Mechanismus: Jeder Schlüssel
im Kontext des Schriftfelds wird ersetzt, und zwar in **beiden** Formen —
`%{author}` und `%author` wirken gleichermaßen.
Die Standardschlüssel sind die Informationsfelder des Folios: `title`, `author`,
`filename`, `folio`, `plant`, `locmach`, `indexrev`, `date`, `display_folio`.
Projekteigenschaften und alle dem Folio hinzugefügten eigenen Felder werden
ebenfalls ersetzt.
Zwei nützliche Einzelheiten:
- Die Schlüssel werden **vom längsten zum kürzesten** ersetzt, mit Absicht.
Sonst fräße ein Schlüssel namens `plant` den Anfang von `%plantcode` und
ließe `code` übrig.
- Nur die geschweifte Form `%{name}` lässt sich *auffinden*: Die Liste der
verwendeten Variablen im Vorlageneditor entsteht durch Suche nach `%{…}`. Ein
nacktes `%name` löst zwar auf, kann aber von nichts aufgezählt werden — in
Vorlagen daher die geschweifte Form bevorzugen.
---
## 8. Ein Durchlauf, in fester Reihenfolge
Formeln werden nicht rekursiv ausgewertet. QET führt eine Folge gewöhnlicher
Textersetzungen aus, in fester Reihenfolge:
1. `%F`, `%f`, `%id`, `%total`, `%M`, `%LM`
2. `%c`, `%l`, `%prefix` (Elemente) bzw. `%wf`, `%wv`, `%wc`, `%ws` (Leiter)
3. Schriftfeldfelder, dann Projekteigenschaften, in beiden Formen `%{name}` und
`%name`
4. Sequenzen
Zwei Folgen daraus:
- **`%F` funktioniert, weil es zuerst expandiert wird.** Es fügt das Foliofeld
ein, das selbst `%id` und `%total` enthalten kann — und die werden im selben
Schritt unmittelbar danach ersetzt. Alles, was das Foliofeld enthält und was
Schritt 1 nicht kennt, überlebt als wörtlicher Text bis auf die Zeichnung.
- **Eine unbekannte Variable ist nie ein Fehler.** Sie wird schlicht nicht
ersetzt. Eine Beschriftung, die `%seqh_3` oder
`%{machine_manufacturer_reference_auxiliary1}` zeigt, ist QETs Art zu sagen,
dass diese Variable hier nicht auflösbar ist.
---
## 9. Kurzübersicht
| Ich möchte… | Nehmen | Wo es wirkt |
|---|---|---|
| die Folionummer | `%f` | Element-/Leiter-/Querverweis-Beschriftungen |
| die Folionummer im Foliofeld | `%id` | nur im Foliofeld |
| Folionummer *und* Gesamtzahl, z. B. `3/12` | `%F` | Element-/Leiter-/Querverweis-Beschriftungen |
| die Rasterposition des Elements | `%l%c` | Elementbeschriftungen |
| eine fortlaufende Nummer | `%sequ_1` | Element-/Leiterbeschriftungen |
| die Sachnummer eines Elements auf der Zeichnung | `%{manufacturer_reference}` | dynamische Texte, Beschriftungen |
| die Anlage im Schriftfeld | `%{plant}` oder `%plant` | Schriftfeldvorlagen |
---
Siehe auch: **[Elemente verknüpfen](element_linking)** ·
**[Die Projektdatenbank](project_database)** ·
[Project XML](project_XML)
+238
@@ -0,0 +1,238 @@
# Variables et formules
Plusieurs champs de QElectroTech acceptent une **formule** — du texte contenant
des variables `%` que QET remplace au moment du dessin. `%f-%l%c` sur une
étiquette d'élément devient `3-B7`. `%id/%total` dans le champ folio devient
`3/12`.
Le piège est qu'il **n'existe pas un seul langage de variables**. Cinq endroits
différents acceptent des formules, chacun résout un jeu différent, et une
variable qui fonctionne à un endroit est silencieusement laissée telle quelle
ailleurs. C'est l'objet de cette page.
Sources : `sources/autoNum/assignvariables.cpp` (`AssignVariables`,
`replaceVariable`), `sources/bordertitleblock.cpp`,
`sources/titleblocktemplate.cpp` (`interpreteVariables`).
---
## 1. Où les formules sont acceptées
| Endroit | Réglé dans | Résout |
|---|---|---|
| **Étiquette d'élément** | informations de l'élément, ou Propriétés du projet → numérotation des éléments | position, folio, séquences, `%{…}` |
| **Texte de conducteur** | propriétés du conducteur → formule, ou numérotation des conducteurs | position, folio, séquences, propriétés du fil |
| **Champ folio** | propriétés du folio → *Folio* | **uniquement** `%autonum`, `%id`, `%total` |
| **Cellules de cartouche** | le modèle `.titleblock` | ce que contient le contexte du cartouche |
| **Étiquettes de renvoi** | Propriétés du projet → renvois | comme les étiquettes d'élément |
---
## 2. Variables de folio et de position
Elles se résolvent sur les étiquettes d'éléments, les textes de conducteurs et
les étiquettes de renvoi.
| Variable | Devient |
|---|---|
| `%f` | l'**indice** du folio, à partir de 1 |
| `%id` | le même indice de folio — `%f` et `%id` sont ici identiques |
| `%F` | le **champ** folio, c'est-à-dire ce que rend le réglage *Folio* du folio |
| `%total` | nombre total de folios du projet |
| `%M` | installation (*plant*) du folio |
| `%LM` | localisation / machine (*locmach*) du folio |
| `%l` | la lettre de ligne de la position de l'élément dans le cadre |
| `%c` | le numéro de colonne de la position de l'élément |
| `%prefix` | le préfixe de l'élément |
### `%f` et `%F` ne sont pas interchangeables
`%f` est l'indice du folio — un simple nombre. `%F` insère le *champ* folio, qui
est lui-même une formule. La valeur par défaut de ce champ est `%id/%total` ;
donc sur le folio 3 sur 12 :
```
%f → 3
%F → 3/12
```
Les deux se lisent naturellement dans une étiquette, ce qui explique que la
différence passe inaperçue — jusqu'au jour où quelqu'un modifie le champ folio
et où toutes les étiquettes changent de forme avec lui. Si vous voulez le
numéro, utilisez `%f`.
### `%c` compte à partir de 0 ou de 1 selon une préférence
Le numéro de colonne sort diminué de un lorsque la préférence *les colonnes
commencent à 0* est active. Le même projet ouvert par deux personnes aux
réglages différents produit des étiquettes différentes. Si les étiquettes
doivent être stables au sein d'une équipe, accordez-vous d'abord sur ce réglage.
---
## 3. Variables de conducteur
Uniquement dans les formules de conducteurs :
| Variable | Devient |
|---|---|
| `%wf` | fonction du conducteur |
| `%wv` | tension / protocole |
| `%wc` | couleur du fil |
| `%ws` | section du fil |
---
## 4. Variables de séquence
La numérotation automatique fournit des séquences numérotées. Chacune existe en
version projet et en version folio, et prend un indice final — `_1` est la
première séquence définie dans ce schéma de numérotation, `_2` la deuxième, etc.
| Famille | Par projet | Par folio |
|---|---|---|
| Unité | `%sequ_1` | `%sequf_1` |
| Dizaine | `%seqt_1` | `%seqtf_1` |
| Centaine | `%seqh_1` | `%seqhf_1` |
| Alphabétique | `%seqa_1` | — |
| Bouclage | `%seqw_1` | — |
Une variable de séquence dont l'indice n'existe pas dans le schéma courant est
**laissée telle quelle dans le texte**. Voir un `%sequ_2` littéral sur un folio
signifie que le schéma ne définit qu'une séquence, non que la numérotation a
échoué.
---
## 5. Variables d'information d'élément — `%{…}`
Les variables entre accolades puisent dans les champs d'information de
l'élément :
```
%{label} %{manufacturer_reference}
```
Les plus courantes : `%{label}`, `%{plant}`, `%{location}`, `%{function}`,
`%{comment}`, `%{description}`, `%{designation}`, `%{manufacturer}`,
`%{manufacturer_reference}`, `%{machine_manufacturer_reference}`,
`%{supplier}`, `%{quantity}`, `%{unity}`.
Également disponibles : `%{auxiliary1}``%{auxiliary4}` et leurs variantes
`description_`, `designation_`, `manufacturer_`, `manufacturer_reference_`,
`supplier_`, `quantity_` et `unity_` ; les champs API `%{plc_type}`,
`%{plc_address}`, `%{plc_function}`, `%{plc_comment}`, `%{plc_crossref}`,
`%{plc_t1}``%{plc_t4}`, `%{plc_tc}` ; les champs de conducteur
`%{conductor_color}`, `%{conductor_section}`, `%{tension_protocol}` ; et
`%{void}`, qui se résout en rien.
### La liste est codée en dur, et quatre champs y manquent
La substitution `%{…}` est une liste fixe dans
`AssignVariables::replaceVariable()`, non une recherche parmi tous les champs
d'information. Un élément porte **57** clés d'information ; **59** variables
entre accolades sont reconnues, et les deux ensembles ne se recouvrent pas
entièrement.
Trois clés sont absentes à dessein — `formula` (c'est *elle*, la formule),
`xref` et `exclude_from_bom` (un indicateur, pas du texte). Mais quatre autres
sont absentes sans raison apparente :
```
%{machine_manufacturer_reference_auxiliary1}
%{machine_manufacturer_reference_auxiliary2}
%{machine_manufacturer_reference_auxiliary3}
%{machine_manufacturer_reference_auxiliary4}
```
Vous pouvez renseigner ces champs sur un élément, et le
`%{machine_manufacturer_reference}` simple se résout normalement — mais les
quatre variantes auxiliaires ne figurent pas dans la liste de substitution et
restent donc sur le dessin sous forme de texte littéral. Si vous avez besoin
d'une référence constructeur machine pour un accessoire, utilisez un autre champ
en attendant la correction.
---
## 6. Variables du champ folio
Le champ folio est l'exception de cette page : il est résolu par une autre
fonction et ne comprend que **trois variables**.
| Variable | Devient |
|---|---|
| `%id` | l'indice de ce folio |
| `%total` | le nombre de folios |
| `%autonum` | la valeur de numérotation automatique du folio |
La valeur par défaut est `%id/%total`. **`%f`, `%l`, `%c`, `%M`, `%LM` et
`%{…}` n'y font rien** — ils restent dans le champ tels quels et seront imprimés
sur chaque folio exactement comme saisis. C'est la déception la plus fréquente
au sujet des variables dans QET.
---
## 7. Variables de cartouche
Les cellules des modèles de cartouche utilisent leur propre mécanisme : toute
clé du contexte du cartouche est substituée, sous **les deux** formes — `%{author}`
et `%author` fonctionnent l'un comme l'autre.
Les clés standard sont les champs d'information du folio : `title`, `author`,
`filename`, `folio`, `plant`, `locmach`, `indexrev`, `date`, `display_folio`.
Les propriétés du projet et tout champ personnalisé ajouté au folio sont
également substitués.
Deux détails utiles :
- Les clés sont substituées **de la plus longue à la plus courte**,
délibérément. Sans cela, une clé nommée `plant` mangerait le début de
`%plantcode` en laissant `code` orphelin.
- Seule la forme entre accolades `%{nom}` peut être *découverte* : la liste des
variables utilisées, dans l'éditeur de modèles, est construite en cherchant
`%{…}`. Un `%nom` nu se résout quand même, mais rien ne peut l'énumérer ;
préférez donc la forme entre accolades dans les modèles.
---
## 8. Une seule passe, dans un ordre fixe
Les formules ne sont pas évaluées récursivement. QET enchaîne de simples
remplacements de texte, dans un ordre fixe :
1. `%F`, `%f`, `%id`, `%total`, `%M`, `%LM`
2. `%c`, `%l`, `%prefix` (éléments) ou `%wf`, `%wv`, `%wc`, `%ws` (conducteurs)
3. les champs du cartouche, puis les propriétés du projet, sous les deux formes
`%{nom}` et `%nom`
4. les séquences
Deux conséquences :
- **`%F` fonctionne parce qu'il est développé en premier.** Il insère le champ
folio, qui peut lui-même contenir `%id` et `%total` — substitués dans la même
étape, juste après. Tout ce que ce champ contient et que l'étape 1 ignore
survivra jusqu'au dessin sous forme de texte littéral.
- **Une variable inconnue n'est jamais une erreur.** Elle n'est simplement pas
remplacée. Une étiquette affichant `%seqh_3` ou
`%{machine_manufacturer_reference_auxiliary1}` est la façon dont QET vous dit
que cette variable n'est pas résoluble ici.
---
## 9. Aide-mémoire
| Je veux… | Utiliser | Où cela marche |
|---|---|---|
| le numéro de folio | `%f` | étiquettes d'élément / conducteur / renvoi |
| le numéro de folio dans le champ folio | `%id` | champ folio uniquement |
| numéro de folio *et* total, p. ex. `3/12` | `%F` | étiquettes d'élément / conducteur / renvoi |
| la position dans le cadre | `%l%c` | étiquettes d'élément |
| un numéro incrémenté | `%sequ_1` | étiquettes d'élément / conducteur |
| la référence d'un élément sur le dessin | `%{manufacturer_reference}` | textes dynamiques, étiquettes |
| l'installation sur un cartouche | `%{plant}` ou `%plant` | modèles de cartouche |
---
Voir aussi : **[Lier des éléments](element_linking)** ·
**[La base de données du projet](project_database)** ·
[Project XML](project_XML)
+229
@@ -0,0 +1,229 @@
# Variables and formulas
Several fields in QElectroTech accept a **formula** — text with `%` variables
that QET substitutes when it draws. `%f-%l%c` on an element label becomes
`3-B7`. `%id/%total` in the folio field becomes `3/12`.
The catch is that **there is no single variable language**. Five different
places accept formulas, each resolves a different set, and a variable that works
in one is silently left as literal text in another. That is what this page is
for.
Sources: `sources/autoNum/assignvariables.cpp` (`AssignVariables`,
`replaceVariable`), `sources/bordertitleblock.cpp`,
`sources/titleblocktemplate.cpp` (`interpreteVariables`).
---
## 1. Where formulas are accepted
| Where | Set in | Resolves |
|---|---|---|
| **Element label** | element information, or Project properties → element auto-numbering | position, folio, sequences, `%{…}` info |
| **Conductor text** | conductor properties → formula, or conductor auto-numbering | position, folio, sequences, wire properties |
| **Folio field** | folio properties → *Folio* | **only** `%autonum`, `%id`, `%total` |
| **Title block cells** | the `.titleblock` template | whatever is in the title-block context |
| **Cross-reference labels** | Project properties → cross-references | same as element labels |
---
## 2. Folio and position variables
These resolve on element labels, conductor texts and cross-reference labels.
| Variable | Becomes |
|---|---|
| `%f` | folio **index**, 1-based |
| `%id` | the same folio index — `%f` and `%id` are identical here |
| `%F` | the folio **field**, i.e. whatever the folio's *Folio* setting renders to |
| `%total` | total number of folios in the project |
| `%M` | plant (*installation*) of the folio |
| `%LM` | location / machine (*locmach*) of the folio |
| `%l` | the row letter of the element's position in the border |
| `%c` | the column number of the element's position |
| `%prefix` | the element's prefix |
### `%f` and `%F` are not interchangeable
`%f` is the folio's index — a plain number. `%F` inserts the folio *field*,
which is itself a formula. QET's default for that field is `%id/%total`, so on
folio 3 of 12:
```
%f → 3
%F → 3/12
```
Both then read naturally in a label, which is why the difference goes unnoticed
until someone changes the folio field and every element label changes shape with
it. If you want the number, use `%f`.
### `%c` counts from 0 or 1 depending on a preference
The column number comes out one lower when the *columns start at 0* preference
is set. The same project opened by two people with different settings produces
different labels. If labels must be stable across a team, agree that setting
first.
---
## 3. Wire variables
Only on conductor formulas:
| Variable | Becomes |
|---|---|
| `%wf` | conductor function |
| `%wv` | tension / protocol |
| `%wc` | wire colour |
| `%ws` | wire section |
---
## 4. Sequence variables
Auto-numbering supplies numbered sequences. Each comes in a per-project and a
per-folio flavour, and each takes a trailing index — `_1` is the first sequence
you defined in that numbering scheme, `_2` the second, and so on.
| Family | Per project | Per folio |
|---|---|---|
| Unit | `%sequ_1` | `%sequf_1` |
| Ten | `%seqt_1` | `%seqtf_1` |
| Hundred | `%seqh_1` | `%seqhf_1` |
| Alphabetic | `%seqa_1` | — |
| Wrap | `%seqw_1` | — |
A sequence variable whose index does not exist in the current numbering scheme
is **left in the text as-is**. Seeing a literal `%sequ_2` on a folio means the
scheme defines only one sequence, not that numbering failed.
---
## 5. Element information variables — `%{…}`
Braced variables pull from the element's own information fields:
```
%{label} %{manufacturer_reference}
```
Commonly used: `%{label}`, `%{plant}`, `%{location}`, `%{function}`,
`%{comment}`, `%{description}`, `%{designation}`, `%{manufacturer}`,
`%{manufacturer_reference}`, `%{machine_manufacturer_reference}`,
`%{supplier}`, `%{quantity}`, `%{unity}`.
Also available: `%{auxiliary1}``%{auxiliary4}` and their
`description_`, `designation_`, `manufacturer_`, `manufacturer_reference_`,
`supplier_`, `quantity_` and `unity_` variants; the PLC fields `%{plc_type}`,
`%{plc_address}`, `%{plc_function}`, `%{plc_comment}`, `%{plc_crossref}`,
`%{plc_t1}``%{plc_t4}`, `%{plc_tc}`; the conductor fields
`%{conductor_color}`, `%{conductor_section}`, `%{tension_protocol}`; and
`%{void}`, which resolves to nothing.
### The list is hard-coded, and four fields are missing from it
`%{…}` substitution is a fixed list in `AssignVariables::replaceVariable()`, not
a lookup over every information field. An element carries **57** information
keys; **59** braced variables are recognised, and they do not fully overlap.
Three keys are absent by design — `formula` (it *is* the formula), `xref`, and
`exclude_from_bom` (a flag, not text). But four more are absent with no apparent
reason:
```
%{machine_manufacturer_reference_auxiliary1}
%{machine_manufacturer_reference_auxiliary2}
%{machine_manufacturer_reference_auxiliary3}
%{machine_manufacturer_reference_auxiliary4}
```
You can fill these fields in on an element, and the plain
`%{machine_manufacturer_reference}` resolves normally — but the four auxiliary
variants are not in the substitution list, so they stay on the drawing as
literal text. If you need a machine manufacturer reference for an accessory,
put it in another field until this is fixed.
---
## 6. Folio field variables
The folio field is the exception on this page: it is resolved by a different
function and understands **three variables only**.
| Variable | Becomes |
|---|---|
| `%id` | this folio's index |
| `%total` | number of folios |
| `%autonum` | the folio auto-numbering value |
The default is `%id/%total`. **`%f`, `%l`, `%c`, `%M`, `%LM` and `%{…}` do
nothing here** — they are left in the field verbatim and will be printed on
every folio exactly as typed. This is the single most common variable
disappointment in QET.
---
## 7. Title block variables
Title block template cells use their own mechanism: every key in the title
block's context is substituted, in **both** the braced and bare forms —
`%{author}` and `%author` both work.
The standard keys are the folio's own information fields: `title`, `author`,
`filename`, `folio`, `plant`, `locmach`, `indexrev`, `date`, `display_folio`.
Project properties and any custom fields you add to the folio are substituted
too.
Two details worth knowing:
- Keys are substituted **longest first**, deliberately. Without that, a key
named `plant` would eat the beginning of `%plantcode` and leave `code`
stranded.
- Only the braced form `%{name}` can be *discovered* — the template editor's
list of variables in use is built by scanning for `%{…}`. A bare `%name` still
resolves, but nothing can enumerate it, so prefer the braced form in
templates.
---
## 8. Substitution is one pass, in a fixed order
Formulas are not evaluated recursively. QET does a sequence of ordinary text
replacements, and the order is fixed:
1. `%F`, `%f`, `%id`, `%total`, `%M`, `%LM`
2. `%c`, `%l`, `%prefix` (elements) or `%wf`, `%wv`, `%wc`, `%ws` (conductors)
3. title-block fields, then project properties, in both `%{name}` and `%name`
forms
4. sequences
Two consequences:
- **`%F` works because it is expanded first.** It inserts the folio field, which
may itself contain `%id` and `%total` — and those are substituted in the same
step, just after. Anything the folio field contains that step 1 does not know
about will survive to the drawing as literal text.
- **An unknown variable is never an error.** It is simply not replaced. A label
showing `%seqh_3` or `%{machine_manufacturer_reference_auxiliary1}` is QET
telling you that variable is not resolvable here.
---
## 9. Quick reference
| I want… | Use | Where it works |
|---|---|---|
| the folio number | `%f` | element / conductor / xref labels |
| the folio number in the folio field | `%id` | folio field only |
| folio number *and* total, e.g. `3/12` | `%F` | element / conductor / xref labels |
| the element's grid position | `%l%c` | element labels |
| an incrementing number | `%sequ_1` | element / conductor labels |
| an element's part number on the drawing | `%{manufacturer_reference}` | dynamic texts, labels |
| the plant on a title block | `%{plant}` or `%plant` | title block templates |
---
See also: **[Linking elements](element_linking)** ·
**[The project database](project_database)** ·
[Project XML](project_XML)