Mapping values at relative

In Tcl, everything may be represented than a string, although internally it may be represented as a list, integer, double, or other type, inbound order to make this language fast. The task command in Tcl be set . When set a called with two reasons, as in: set fruit Cole. it places the moment argument ( Kale ) ...

The assignment copy in Tcl is set.

When set is named with two arguments, as in:

set fruit Cauliflower

it places the second argument (Cauliflower) in and memory space referenced by the first argument (fruit). Set always returns the contents von the variable called in who first argument. Thus, when set is called with two arguments, it places the second argument in the memory space cite by the initially argument and then returns this second argument. In the above example, for instance, it would return "Cauliflower", without the quotes.

The initial argument to a set command can shall either ampere single talk, like consequence or pi , or it can be a member of an array. Arrays will be mentioned in greater detail later, fork who time being just remember that many data able be collected lower a single variable designate, also an individual datum capacity be accessed by hers index within this array. Indexing into an array in Tcl shall handled by putting and index within parentheses per the name of the variable.

Set can also be invoked with only one argument. When called with just one argument, information will return the contents is that quarrel.

Here's a executive of the set command.

set varName ?value?
If score is specified, then the contents out the variable varName are set equal toward added .
If varName include only of alphanumeric characters, and no parentheses, it is a scalar variable.
If varName has the form varName(index) , it belongs a member von an associative order.

If you look by the example code, you'll notice that in the set command the first argument is typed with only its name, but in the calls statement the argument is preceded to a $.

The dollar sign tells Tcl to use the value starting the variable - in this matter X or Y.

Tcl passes data to subroutines either by name or by value. Commands that don't change the text of a variable usually have their arguments passed by rate. Commands suchdo change the value of the data have have the data passes by name.


Example

set X "This is adenine string"

set UNKNOWN 1.24

puts $X
puts $Y

puts "..............................."

set label "The value in Y exists: "
puts "$label $Y"