Variables In TCL
Variable is a lifeline for a programming language. It provides a mechanism to a programming language to name a portion of a memory and reference a data stored there.
We use assignment operation to set a particular value to a variable. In TCL, we use set command for assignment. we can use set command in two ways.
set pi 3.14; # assigning a value (case 1)
set pi; # reading a variable (case 2)
In Hello TCL, we get introduced to TCL language.
In case 1, a variable named pi is being assigned a value 3.14. We can also assign a string to a variable. After assigning a value to a variable, set command returns the value. In this example, 3.14.
In case 2, set command merely returns the value assigned to this variable. In this example, 3.14. Another way to read the value of a variable is prefixing the variable with $ e.g. $pi. Here is an example,
puts $pi
Comments
Post a Comment