Sophie

Sophie

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

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

<HTML><HEAD><TITLE>Built-In Commands - while manual page</TITLE></HEAD><BODY>
<H3><A NAME="M2">NAME</A></H3>
while - Execute script repeatedly as long as a condition is met
<H3><A NAME="M3">SYNOPSIS</A></H3>
<B>while </B><I>test body</I><BR>
<H3><A NAME="M4">DESCRIPTION</A></H3>
The <B>while</B> command evaluates <I>test</I> as an expression
(in the same way that <B><A HREF="../TclCmd/expr.htm">expr</A></B> evaluates its argument).
The value of the expression must a proper boolean
value; if it is a true value
then <I>body</I> is executed by passing it to the Tcl interpreter.
Once <I>body</I> has been executed then <I>test</I> is evaluated
again, and the process repeats until eventually <I>test</I>
evaluates to a false boolean value.  <B><A HREF="../TclCmd/continue.htm">Continue</A></B>
commands may be executed inside <I>body</I> to terminate the current
iteration of the loop, and <B><A HREF="../TclCmd/break.htm">break</A></B>
commands may be executed inside <I>body</I> to cause immediate
termination of the <B>while</B> command.  The <B>while</B> command
always 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>while</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>set x 0
while {$x&lt;10} {
	puts &quot;x is $x&quot;
	incr x
}</PRE>
<H3><A NAME="M5">KEYWORDS</A></H3>
<A href="../Keywords/B.htm#boolean value">boolean value</A>, <A href="../Keywords/L.htm#loop">loop</A>, <A href="../Keywords/T.htm#test">test</A>, <A href="../Keywords/W.htm#while">while</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>