Zum Inhalt springen

Vorlage:booland/Doku

aus Wikipedia, der freien Enzyklopädie

Vorlage:Dokumentation/Seitenhinweis

[Vorlagenprogrammierung] Logische Und-Verknüpfung von zwei oder mehr Werten

<templatestyles src="TOC nonum/styles.css"></templatestyles>

⧼templatedata-doc-params⧽

1. Wert1
1. Wert zur Verknüpfung
2. Wert2
2. Wert zur Verknüpfung
weiterer Wert3
Weiterer Wert zur Verknüpfung
weitere Werte4
Beliebig viele weitere Werte zur Verknüpfung

Kopiervorlage

<syntaxhighlight lang="wikitext" copy>



</syntaxhighlight>

Hinweise

Im Unterschied zur Wikisyntax werden nicht nur leere Strings als „false“ betrachtet, sondern auch solche, welche 0, - oder false enthalten.

Die Vorlage erzeugt einen nichtleeren String (1, also „wahr“), wenn alle Parameter nach vorstehender Regel „wahr“ sind, ansonsten einen leeren String.

Ein leerer Parameter, also auch etwa |}}, bewirkt stets ein logisches „falsch“.

Alle Parameter müssen erst ausgewertet werden, bevor sie verknüpft werden können. Das ist ein Problem, wenn die Ermittlung aufwändig ist („teuer“ oder sonst performancekritisch). Besser ist dann: <syntaxhighlight lang="wikitext" copy> {{#if: Vorlage:A-Vorlage

 | <Aktion>

</syntaxhighlight>

Beispiele

  • {{#if: {{booland|| }} | Ja | Nein}} ergibt

Nein

  • {{#if: {{booland|xxx| }} | Ja | Nein}} ergibt

Nein

  • {{#if: {{booland| |yyy}} | Ja | Nein}} ergibt

Nein

  • {{#if: {{booland|xxx|yyy}} | Ja | Nein}} ergibt

Ja

  • {{#if: {{booland|xxx|yyy| }} | Ja | Nein}} ergibt

Nein

  • {{#if: {{booland|xxx|yyy|}} | Ja | Nein}} ergibt

Nein

Wahrheitstabellen

Zwei Parameter
Eingabe Ausgabe
{{booland| | }}
{{booland| |1}}
{{booland|1| }}
{{booland|1|1}} 1
Drei Parameter
Eingabe Ausgabe
{{booland| | | }}
{{booland| |1| }}
{{booland|1| | }}
{{booland|1|1| }}
{{booland| | |1}}
{{booland| |1|1}}
{{booland|1| |1}}
{{booland|1|1|1}} 1
Vier Parameter
Eingabe Ausgabe
{{booland| | | | }}
{{booland| |1| | }}
{{booland|1| | | }}
{{booland|1|1| | }}
{{booland| | |1| }}
{{booland| |1|1| }}
{{booland|1| |1| }}
{{booland|1|1|1| }}
{{booland| | | |1}}
{{booland| |1| |1}}
{{booland|1| | |1}}
{{booland|1|1| |1}}
{{booland| | |1|1}}
{{booland| |1|1|1}}
{{booland|1| |1|1}}
{{booland|1|1|1|1}} 1

Siehe auch