Logical Expressions in WebLord, the Document Assembly Tool
Logo WebLord v2.2
The Document Assembly Tool

Boolean Expressions

A boolean expression evaluates to either TRUE or FALSE.

WebLord's boolean expressions are a combination of one or more simple expressions, connected by boolean operators (AND, OR, XOR). We will look at simple expressions first, then examine the function of boolean operators.

Simple Expressions

A simple expression takes one of two forms, a comparison or define-test:

  1. value operator value
    where 'value' is either a property, an object or the property of a specific object, a macro invocation, or a constant string;
    'operator' is a constant (i.e. quoted!) string, one of the following:

    Comparison Operators Meaning
    "=" "==" "eq" equality
    "!=" "<>" "ne" inequality
    "<" "lt" less than
    "<=" "le" less than or equal
    ">" "gt" greater than
    >=" "ge" greater than or equal
    "$" "contains" contains a substring

  2. isdef v    OR   isdef [ v1 v2 v3 ... vN ]
    ISDEF is a keyword (may also be spelled ISDEFINED, DEF, or DEFINED) that is followed by one property or object name, or a list of such property or object names enclosed in parentheses. The parentheses may either be "[" and "]" or "(" and ")" (i.e. square brackets or (round) parentheses. Parentheses must be quoted (otherwise WebLord would parse them as a macro argument list.)

Examples:

  • parent.objectname '=' "Amiga"
  • parent.objecttype '!=' "page"
  • rootpage.objectname '==' page.objectname
  • isdefined Amiga
  • isdefined author.email
  • isdef '[' author email url ']'

Complex Expressions

A complex expression consists of two or more simple expressions separated by a boolean operator.

Boolean Operators Meaning
"and" "&" "&& left and right side must be true
"or" "|" "||" either left or right side must be true
"xor" "^" "^^" either but not both sides must be true

The following reference table may help illustrate the relationship. Tilt your head about 45° to the left, then read one of the left edges, the boolean operator, and the right edge: 'true AND true' is 'TRUE'

AND true false
true TRUE false
false false false
OR true false
true TRUE TRUE
false TRUE false
XOR true false
true false TRUE
false TRUE false

Examples:

  • '[' parent.objectname '=' "Amiga" ']' "and" '[' isdef author.email ']'
  • parent.objecttype '!=' "page" "&" rootpage.objectname '==' page.objectname

Negation Operator

Both simple and complex expressions may be preceded by a keyword "NOT" to change 'true' to 'false' and vice versa. This negation operator may also be written as "!" or "~"

Examples:

  • "not" '[' '[' parent.objectname '=' "Amiga" ']' "and" '[' isdef author.email ']' ']'
  • parent.objecttype '!=' "page" "&" "not" rootpage.objectname '!=' page.objectname
  • "not" isdef demoobject

Evaluation Order

Evaluation order is strictly left-to-right. You must enclose portions of the expression in parentheses (or brackets) to assert full control over the evaluation order. In addition, no short-circuit evaluation will be performed.


This material is Copyright © 1997,1998,1999,2000,2001 RingLord Technologies and Udo Schuermann. All rights reserved. The latest versions of the WebLord software and (this) documentation can be obtained from the WebLord Home Page (the link will only function if you are connected to the internet.)