Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bd5c3d824c3db63ffd9226c15941e6ad > files > 1962

mozart-1.4.0-1mdv2010.0.i586.rpm

<HTML><HEAD><TITLE>Built-In Commands - for manual page</TITLE></HEAD><BODY>
<H3><A NAME="M2">NAME</A></H3>
for - ``For'' loop
<H3><A NAME="M3">SYNOPSIS</A></H3>
<B>for </B><I>start test next body</I><BR>
<H3><A NAME="M4">DESCRIPTION</A></H3>
<B>For</B> is a looping command, similar in structure to the C
<B>for</B> statement.  The <I>start</I>, <I>next</I>, and
<I>body</I> arguments must be Tcl command strings, and <I>test</I>
is an expression string.
The <B>for</B> command first invokes the Tcl interpreter to
execute <I>start</I>.  Then it repeatedly evaluates <I>test</I> as
an expression; if the result is non-zero it invokes the Tcl
interpreter on <I>body</I>, then invokes the Tcl interpreter on <I>next</I>,
then repeats the loop.  The command terminates when <I>test</I> evaluates
to 0.  If a <B><A HREF="../TclCmd/continue.htm">continue</A></B> command is invoked within <I>body</I> then
any remaining commands in the current execution of <I>body</I> are skipped;
processing continues by invoking the Tcl interpreter on <I>next</I>, then
evaluating <I>test</I>, and so on.  If a <B><A HREF="../TclCmd/break.htm">break</A></B> command is invoked
within <I>body</I>
or <I>next</I>,
then the <B>for</B> command will
return immediately.
The operation of <B><A HREF="../TclCmd/break.htm">break</A></B> and <B><A HREF="../TclCmd/continue.htm">continue</A></B> are similar to the
corresponding statements in C.
<B>For</B> returns an empty string.
<P>
Note: <I>test</I> should almost always be enclosed in braces.  If not,
variable substitutions will be made before the <B>for</B>
command starts executing, which means that variable changes
made by the loop body will not be considered in the expression.
This is likely to result in an infinite loop.  If <I>test</I> is
enclosed in braces, variable substitutions are delayed until the
expression is evaluated (before
each loop iteration), so changes in the variables will be visible.
For an example, try the following script with and without the braces
around <B>$x&lt;10</B>:
<PRE>for {set x 0} {$x&lt;10} {incr x} {
	puts &quot;x is $x&quot;
}</PRE>
<H3><A NAME="M5">KEYWORDS</A></H3>
<A href="../Keywords/F.htm#for">for</A>, <A href="../Keywords/I.htm#iteration">iteration</A>, <A href="../Keywords/L.htm#looping">looping</A>
<HR><PRE>
<A HREF="../copyright.htm">Copyright</A> &#169; 1993 The Regents of the University of California.
<A HREF="../copyright.htm">Copyright</A> &#169; 1994-1997 Sun Microsystems, Inc.
<A HREF="../copyright.htm">Copyright</A> &#169; 1995-1997 Roger E. Critchlow Jr.</PRE>
</BODY></HTML>