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