|
|
Section Intro: Flow Control
Flow ControlSynopsis: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 Commands: Variables:
Unconditionally and immediately stop the execution of the nearest
surrounding Example usage: <while true>
;;; Check to see if the user has changed the file.
<if <file-newer? <get-var foo.c> <get-var foo.o>>
<break>>
<p>
;;; Not changed yet, so do some more in the background.
<process-chunk <get-var chunk-num>>
<increment chunk-num>
</while>
Concatenate all of the arguments given, creating a single token with no intervening whitespace. This is quite useful for those situations where intervening whitespace would look bad in the output, but the input source would be unreadable without any. For example: <concat <textarea name=label rows=10 cols=40>
<get-var-once label>
</textarea>>
Combine all of the material passed into a single Meta-HTML statement. This is the primitive for grouping multiple statements where only a single statement is expected. Whitespace within the group is preserved, making this command useful for assigning to array variables. Some examples: <set-var array[] =
<group this is element 0
this is element 1
this is element 2>>
<if <eq this that>
<group <h2> This is equal to That </h2>>
<group <h2> This is NOT equal to That </h2>>>
Although <defsubst group &body body><get-var-once body></defsubst>
First TEST is evaluated. If the result does not contain only
whitespace characters the THEN clause is evaluated, otherwise,
the ELSE clause is evaluated. Although Meta-HTML has the
relational operator <if <get-var foo bar> "Either FOO or BAR is present" "Neither FOO nor BAR is present">
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.
The THIS and THAT clauses are evaluated. If the results are not 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.
For each NAME=VALUE pair, the value of NAME is
compared with the regular expression REGEXP. If the expression matches,
then the corresponding CONSEQUENT code is performed, and its value is
the return value of the
If none of the clauses match, and there is a
Synonym for
Unconditionally and immediately stop the execution of the current
function, macro, Example usage: <define-function countdown start stop>
<if <eq start stop>
<return BlastOff!>>
<get-var start>,
<countdown <sub start 1> <get-var stop>>
</define-function>
<countdown 10 4>
produces:
10, 9, 8, 7, 6, 5, BlastOff!
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
If none of the clauses match, and there is a
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>>>
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
TEST is evaluated. If the result is a non-empty string, then the BODY statements are evaluated, and the process is repeated.
Execute BODY in an environment where VAR has the value
VAL. Execution takes place in the current package. After
execution, the value of VAR is restored to the value that it
had before encountering the
<set-var x=hello> <with x=1 z=<get-var foo>> <get-var x> </with> <get-var x>produces: 1 hello
Edit Section
![]() The META-HTML Reference Manual V2.0 Copyright © 1995, 1998, Brian J. Fox Found a bug? Send mail to bug-manual@metahtml.org |