Top
Systemwalker Operation Manager V17.0.1 Reference Guide

15.2.13 incr (Add a Value to a Variable)

Description

Adds a value to a variable.

Synopsis

incr varname [increment]

Options

varname

Specify the name of variable to be added. This variable must hold a decimal integer. The result of addition is also stored in this variable.

increment

Specify the value to be added (a decimal integer). If this option is omitted, 1 is added.

Return Value

The result of addition (i.e. $varname + increment before incr command is called)

Caution

If both the variable specified by varname and the value of increment are not decimal integers, the script is forced to exit upon detecting the occurrence of an exception. When using this command, trap exceptions using the catch command where necessary.

Example

The following example shows the count values for the last three looping sequences of the five iterations.

set i 0
while {$i < 5} {
      incr i
      if {$i < 3} {
            continue
      }
      puts $i
}

Execution Results/Output Format

3
4
5