[25] | 1 | '\" |
---|
| 2 | '\" Copyright (c) 1993 The Regents of the University of California. |
---|
| 3 | '\" Copyright (c) 1994-1996 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: incr.n,v 1.6 2006/02/09 17:34:41 dgp Exp $ |
---|
| 9 | '\" |
---|
| 10 | .so man.macros |
---|
| 11 | .TH incr n "" Tcl "Tcl Built-In Commands" |
---|
| 12 | .BS |
---|
| 13 | '\" Note: do not modify the .SH NAME line immediately below! |
---|
| 14 | .SH NAME |
---|
| 15 | incr \- Increment the value of a variable |
---|
| 16 | .SH SYNOPSIS |
---|
| 17 | \fBincr \fIvarName \fR?\fIincrement\fR? |
---|
| 18 | .BE |
---|
| 19 | |
---|
| 20 | .SH DESCRIPTION |
---|
| 21 | .PP |
---|
| 22 | Increments the value stored in the variable whose name is \fIvarName\fR. |
---|
| 23 | The value of the variable must be an integer. |
---|
| 24 | If \fIincrement\fR is supplied then its value (which must be an |
---|
| 25 | integer) is added to the value of variable \fIvarName\fR; otherwise |
---|
| 26 | 1 is added to \fIvarName\fR. |
---|
| 27 | The new value is stored as a decimal string in variable \fIvarName\fR |
---|
| 28 | and also returned as result. |
---|
| 29 | .PP |
---|
| 30 | .VS 8.5 |
---|
| 31 | Starting with the Tcl 8.5 release, the variable \fIvarName\fR passed |
---|
| 32 | to \fBincr\fR may be unset, and in that case, it will be set to |
---|
| 33 | the value \fIincrement\fR or to the default increment value of \fB1\fR. |
---|
| 34 | .VE 8.5 |
---|
| 35 | .SH EXAMPLES |
---|
| 36 | Add one to the contents of the variable \fIx\fR: |
---|
| 37 | .CS |
---|
| 38 | \fBincr\fR x |
---|
| 39 | .CE |
---|
| 40 | .PP |
---|
| 41 | Add 42 to the contents of the variable \fIx\fR: |
---|
| 42 | .CS |
---|
| 43 | \fBincr\fR x 42 |
---|
| 44 | .CE |
---|
| 45 | .PP |
---|
| 46 | Add the contents of the variable \fIy\fR to the contents of the |
---|
| 47 | variable \fIx\fR: |
---|
| 48 | .CS |
---|
| 49 | \fBincr\fR x $y |
---|
| 50 | .CE |
---|
| 51 | .PP |
---|
| 52 | Add nothing at all to the variable \fIx\fR (often useful for checking |
---|
| 53 | whether an argument to a procedure is actually integral and generating |
---|
| 54 | an error if it is not): |
---|
| 55 | .CS |
---|
| 56 | \fBincr\fR x 0 |
---|
| 57 | .CE |
---|
| 58 | |
---|
| 59 | .SH "SEE ALSO" |
---|
| 60 | expr(n) |
---|
| 61 | |
---|
| 62 | .SH KEYWORDS |
---|
| 63 | add, increment, variable, value |
---|