Name: FOREACH
Section:
Arrays
Synopsis:
<foreach ELEMENTVAR ARRAYVAR [START=X] [END=X] [STEP=X]>
%body
</foreach>
Description:
Perform BODY with ELEMENTVAR bound to successive
memebers of ARRAYVAR, starting with the element at START (default 0), and ending at END (default
<array-size ARRAYVAR>
), advancing by STEP (default 1).
The foreach
command is the basic array looping device in Meta-HTML. It is guaranteed to iterate over each element that you specify, whether that element is the empty string or not.
Starting with the simple array:
<set-var array[]="0\n1\n2\n3\n4\n5\n6\n7\n8\n9">
we can print out the odd numbers of this array by using values for both START and STEP:
<foreach x array start=1 step=2> <get-var x>, </foreach>
produces:
1, 3, 5, 7, 9,
or, we can produce a "countdown" with a negative value for STEP:
<foreach x array step=-1> <get-var x>, </foreach> BOOM!
produces:
9, 8, 7, 6, 5, 4, 3, 2, 1, 0, BOOM!
Edit Pointer
Function Index
Variable Index
Variable Editor

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