for man page on OpenIndiana

Man page or keyword search:  
man Server   20441 pages
apropos Keyword Search (all sections)
Output format
OpenIndiana logo
[printable version]

for(1T)			     Tcl Built-In Commands		       for(1T)

______________________________________________________________________________

NAME
       for - ``For'' loop

SYNOPSIS
       for start test next body
_________________________________________________________________

DESCRIPTION
       For  is a looping command, similar in structure to the C for statement.
       The start, next, and body arguments must be Tcl	command	 strings,  and
       test  is	 an  expression string.	 The for command first invokes the Tcl
       interpreter to execute start.  Then it repeatedly evaluates test as  an
       expression; if the result is non-zero it invokes the Tcl interpreter on
       body, then invokes the Tcl interpreter on next, then repeats the	 loop.
       The command terminates when test evaluates to 0.	 If a continue command
       is invoked within body then any remaining commands in the current  exe‐
       cution  of  body	 are skipped; processing continues by invoking the Tcl
       interpreter on next, then evaluating test, and so on.  If a break  com‐
       mand  is	 invoked within body or next, then the for command will return
       immediately.  The operation of break and continue are  similar  to  the
       corresponding statements in C.  For returns an empty string.

       Note:  test  should almost always be enclosed in braces.	 If not, vari‐
       able substitutions will be made before the for command  starts  execut‐
       ing,  which  means that variable changes made by the loop body will not
       be considered in the expression.	 This is likely to result in an	 infi‐
       nite  loop.   If test 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.  See below for an example:

EXAMPLES
       Print a line for each of the integers from 0 to 10:
	      for {set x 0} {$x<10} {incr x} {
		 puts "x is $x"
	      }

       Either loop infinitely or not at all because the expression being eval‐
       uated is actually the constant, or even generate an error!  The	actual
       behaviour  will	depend on whether the variable x exists before the for
       command is run and whether its value is a value that is	less  than  or
       greater	than/equal  to ten, and this is because the expression will be
       substituted before the for command is executed.
	      for {set x 0} $x<10 {incr x} {
		 puts "x is $x"
	      }

       Print out the powers of two from 1 to 1024:
	      for {set x 1} {$x<=1024} {set x [expr {$x * 2}]} {
		 puts "x is $x"
	      }

SEE ALSO
       break, continue, foreach, while

KEYWORDS
       for, iteration, looping

ATTRIBUTES
       See attributes(5) for descriptions of the following attributes:

       ┌────────────────────┬─────────────────┐
       │  ATTRIBUTE TYPE    │ ATTRIBUTE VALUE │
       ├────────────────────┼─────────────────┤
       │Availability	    │ runtime/tcl-8   │
       ├────────────────────┼─────────────────┤
       │Interface Stability │ Uncommitted     │
       └────────────────────┴─────────────────┘
NOTES
       Source for Tcl is available on http://opensolaris.org.

Tcl								       for(1T)
[top]

List of man pages available for OpenIndiana

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net