| THE META-HTML LANGUAGE REFERENCE MANUAL

Packages | [TOC] | Arithmetic Operators

## Section Intro: Flow Control

Synopsis:

Meta-HTML contains commands for controlling which of a set of statements will be executed, and for repetitive execution of a set of statements.

Such commands constitute what is called flow control, since they tell the Meta-HTML interpreter where or what the next statement to interpret resides.

All of the flow control operators in Meta-HTML take a test and some additional statements; the closest thing to a goto statement in Meta-HTML is the `redirect` command.

Commands:

if ifeq | redirect server-push | var-case when | while

### Function Documentation

`<if TEST [THEN] [ELSE]>` | Simple

First TEST is evaluated. If the result is a non-whitespace only string, the THEN clause is evaluated, otherwise, the ELSE clause is evaluated. Although Meta-HTML has an `or` function, you can efficiently test for the presence of any of a group of variables with code similar to the following:

      <if <get-var foo bar>
          "Either FOO or BAR is present"
        "Neither FOO nor BAR is present">

`<ifeq THIS THAT [THEN] [ELSE] [CASELESS=TRUE]>` | Simple

The THIS and THAT clauses are evaluated. If the results are text-wise identical, then the THEN clause is evaluated, otherwise, the ELSE clause is evaluated. If CASELESS=TRUE is given, the text-wise comparison of the values is done with no regard to upper and lower case distinctions.

`<redirect URL>` | Simple

Immediately return the HTTP Location directive with URL. This command is extremely useful in conjunction with `var-case`; in effect, that usage creates a dispatch table.

`<server-push> body </server-push>` | Complex

This command will be made obsolete.

Its functionality is available other, cleaner ways, specifically through the use of `with-open-stream` and the variable `*standard-output*`.

Just write it as a `defmacro`.

`<var-case [{NAME=VALUE] [CONSEQUENT}...] [DEFAULT] [DEFAULT-CONSEQUENT]>` | Simple

For each NAME=VALUE pair, the value of NAME is string-wise compared with VALUE. If they are identical, then the corresponding CONSEQUENT code is performed, and its value is the return value of the `<var-case>` form.

If none of the clauses match, and there is a `DEFAULT` clause, then the DEFAULT-CONSEQUENT is evaluated, and its return value is the return value of the `<var-case>` form.

`var-case` is especially useful as a `traffic switch' to select one of several actions based on a user button press.

For example:

    <var-case
       action="Save Files"	      <save-files <get-var posted::files[]>>
       action="Delete Files"      <delete-files <get-var posted::files[]>>
       action="Rename Files"      <redirect
                                     rename-files.mhtml?<cgi-encode files>>>

`<when TEST> body </when>` | Complex

Evaluate TEST. If the result is a non-empty string, then execute the BODY statements. This is a cleaner way to handle optional multiple statement execution rather than dealing with quoting everything inside of an `if` form.

`<while TEST> body </while>` | Complex

TEST is evaluated. If the result is a non-empty string, then the BODY statements are evaluated, and the process is repeated.

Edit Section
Function Index
Variable Index

The META-HTML Reference Manual V1.4 Copyright © 1995, 1996, Brian J. Fox, 1996, 1997 Universal Access Inc.
Found a bug? Send mail to bug-manual@metahtml.com