Go to main content

man pages section 1: User Commands

Exit Print View

Updated: Wednesday, July 27, 2022
 
 

incr (1t)

Name

incr - Increment the value of a variable

Synopsis

incr varName ?increment?

Description

incr(1t)                     Tcl Built-In Commands                    incr(1t)



______________________________________________________________________________

NAME
       incr - Increment the value of a variable

SYNOPSIS
       incr varName ?increment?
______________________________________________________________________________

DESCRIPTION
       Increments the value stored in the variable whose name is varName.  The
       value of the variable must be an integer.   If  increment  is  supplied
       then  its  value  (which  must  be an integer) is added to the value of
       variable varName;  otherwise 1 is added to varName.  The new  value  is
       stored  as  a  decimal  string in variable varName and also returned as
       result.

       Starting with the Tcl 8.5 release, the variable varName passed to  incr
       may  be  unset, and in that case, it will be set to the value increment
       or to the default increment value of 1.

EXAMPLES
       Add one to the contents of the variable x:

              incr x

       Add 42 to the contents of the variable x:

              incr x 42

       Add the contents of the variable y to the contents of the variable x:

              incr x $y

       Add nothing at all to the variable x (often useful for checking whether
       an argument to a procedure is actually integral and generating an error
       if it is not):

              incr x 0


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


       +---------------+------------------+
       |ATTRIBUTE TYPE | ATTRIBUTE VALUE  |
       +---------------+------------------+
       |Availability   | runtime/tcl-8    |
       +---------------+------------------+
       |Stability      | Uncommitted      |
       +---------------+------------------+

SEE ALSO
       expr(n), set(n)

KEYWORDS
       add, increment, variable, value



NOTES
       Source code for open source software components in Oracle  Solaris  can
       be found at https://www.oracle.com/downloads/opensource/solaris-source-
       code-downloads.html.

       This    software    was    built    from    source     available     at
       https://github.com/oracle/solaris-userland.    The  original  community
       source was downloaded from  http://prdownloads.sourceforge.net/tcl/tcl-
       core8.6.7-src.tar.gz.

       Further information about this software can be found on the open source
       community website at https://www.tcl.tk/.



Tcl                                                                   incr(1t)