THE META-HTML LANGUAGE REFERENCE MANUAL

Arithmetic Operators [TOC] String Operators

Section Intro: Relational Operators

Relational Operators

Synopsis:

    Relational operators in Meta-HTML return information about the relationship between two items. There are three logical operators, and, or, and not.

    There are several other operators which compare numeric values; the section Arithmetic Operators cover those in detail.

Commands:

<and &rest expr...>Simple

    and evaluates each EXPR given until one of them evaluates to the empty string, or until they are all exhausted. The result is the result of the last evaluation. Evaluating just <and> returns "true".

    Examples:

    <and>                    ==> true
    <and this that>          ==> that
    <unset-var foo>
    <and <get-var foo> this> ==>
    <and this <get-var foo>> ==>
    <set-var foo=bar>
    <and this long list <get-var foo>> ==> bar

    <and> could have been defined in Meta-HTML as follows:

    <define-tag and &unevalled &rest expressions[] whitespace=delete>
      <set-var result=true>
      <foreach :expr expressions>
        <set-var result = <get-var-eval :expr>>
        <if <not <get-var-once result>>
          <break>>
      </foreach>
      <get-var-once result>
    </define-tag>

<not &optional [BODY]Simple

    BODY is evaluated. If the result is the empty string, then the string "true" is returned, otherwise nothing is returned. BODY is simply the entire contents of the simple tag, with the word "not" in it. Thus, in typical usage one might write:

    <when <not <get-var foo>>>
      Hey!  You didn't set the variable FOO.
    </when>

<or &rest expr...>Simple

    or evaluates each EXPR given until one of them evaluates to a non-empty string, or until they are all exhausted. The result is the result of the last evaluation. Evaluating just <or> returns the empty string.

    Examples:

    <or>                    ==> 
    <or this that>          ==> this
    <unset-var foo>
    <or <get-var foo> this> ==> this
    <or this <get-var foo>> ==> this
    <set-var foo=bar>
    <or <get-var foo> this> ==> bar

    <or> could have been defined in Meta-HTML as follows:

    <define-tag or &unevalled &rest expressions[] whitespace=delete>
      <foreach :expr expressions>
        <set-var result = <get-var-eval :expr>>
        <if <get-var-once result>
            <break>>
      </foreach>
      <get-var-once result>
    </define-tag>

Edit Section
Function Index
Variable Index


The META-HTML Reference Manual V2.0 Copyright © 1995, 1998, Brian J. Fox
Found a bug? Send mail to bug-manual@metahtml.org