OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tcl/] [doc/] [for.n] - Blame information for rev 1771

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
'\"
2
'\" Copyright (c) 1993 The Regents of the University of California.
3
'\" Copyright (c) 1994-1997 Sun Microsystems, Inc.
4
'\"
5
'\" See the file "license.terms" for information on usage and redistribution
6
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7
'\"
8
'\" RCS: @(#) $Id: for.n,v 1.1.1.1 2002-01-16 10:25:24 markom Exp $
9
'\"
10
.so man.macros
11
.TH for n "" Tcl "Tcl Built-In Commands"
12
.BS
13
'\" Note:  do not modify the .SH NAME line immediately below!
14
.SH NAME
15
for \- ``For'' loop
16
.SH SYNOPSIS
17
\fBfor \fIstart test next body\fR
18
.BE
19
 
20
.SH DESCRIPTION
21
.PP
22
\fBFor\fR is a looping command, similar in structure to the C
23
\fBfor\fR statement.  The \fIstart\fR, \fInext\fR, and
24
\fIbody\fR arguments must be Tcl command strings, and \fItest\fR
25
is an expression string.
26
The \fBfor\fR command first invokes the Tcl interpreter to
27
execute \fIstart\fR.  Then it repeatedly evaluates \fItest\fR as
28
an expression; if the result is non-zero it invokes the Tcl
29
interpreter on \fIbody\fR, then invokes the Tcl interpreter on \fInext\fR,
30
then repeats the loop.  The command terminates when \fItest\fR evaluates
31
to 0.  If a \fBcontinue\fR command is invoked within \fIbody\fR then
32
any remaining commands in the current execution of \fIbody\fR are skipped;
33
processing continues by invoking the Tcl interpreter on \fInext\fR, then
34
evaluating \fItest\fR, and so on.  If a \fBbreak\fR command is invoked
35
within \fIbody\fR
36
or \fInext\fR,
37
then the \fBfor\fR command will
38
return immediately.
39
The operation of \fBbreak\fR and \fBcontinue\fR are similar to the
40
corresponding statements in C.
41
\fBFor\fR returns an empty string.
42
.PP
43
Note: \fItest\fR should almost always be enclosed in braces.  If not,
44
variable substitutions will be made before the \fBfor\fR
45
command starts executing, which means that variable changes
46
made by the loop body will not be considered in the expression.
47
This is likely to result in an infinite loop.  If \fItest\fR is
48
enclosed in braces, variable substitutions are delayed until the
49
expression is evaluated (before
50
each loop iteration), so changes in the variables will be visible.
51
For an example, try the following script with and without the braces
52
around \fB$x<10\fR:
53
.CS
54
for {set x 0} {$x<10} {incr x} {
55
        puts "x is $x"
56
}
57
.CE
58
 
59
.SH KEYWORDS
60
for, iteration, looping

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.