3. Variables

Tcl supports two kinds of variables: simple variables (often referred to as scalar variables) and associative arrays. This chapter describes the basic Tcl commands for manipulating variables and arrays, and it also provides a more complete description of variable substitution.

3.1 Commands Presented in This Chapter

This chapter discusses the following basic commands for manipulating variables:

append varName value ?value ...?

Appends each of the value arguments to the variable varName, in order. If varName doesn’t exist, it is created with an empty value before appending occurs. The return value is the new value of varName.

incr varName ?increment?

Adds increment to the value of the variable varName. Both increment and the ...

Get Tcl and the Tk Toolkit, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.