Zum Inhalt springen

Vorlage:booland

aus Wikipedia, der freien Enzyklopädie


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

Vorlagenparameter

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

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

Vorlagenparameter[Vorlagendaten bearbeiten]

ParameterBeschreibungTypStatus
1. Wert1

1. Wert zur Verknüpfung

Wahrheitswerterforderlich
2. Wert2

2. Wert zur Verknüpfung

Wahrheitswerterforderlich
weiterer Wert3

Weiterer Wert zur Verknüpfung

Wahrheitswertoptional
weitere Werte4

Beliebig viele weitere Werte zur Verknüpfung

Wahrheitswertoptional

Kopiervorlage

{{booland| | }}
{{booland| | | }}
{{booland| | | | }}
{{booland| | | | | }}
{{booland| | | | | | }}

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:

{{#if: {{A-Vorlage}}
  | {{#if: {{B-Vorlage}}
      | {{#if: {{C-Vorlage}}
          | <Aktion> }} }}

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

Lua

Verwendetes Modul: Expr #TemplateBooland