Braces, quotes, and square brackets control when variables and commands are processed. They are also used to group parameters.
The example below illustrates that HyperWorks Desktop will not recognize arguments if they are not distinguished somehow:
set var1 HyperWorks uses Tcl and Tk;
In order to distinguish the arguments in a command string, you must use quotes or braces as shown in these examples:
set var1 "HyperWorks uses Tcl and Tk";
set var1 {HyperWorks uses Tcl and Tk};
Variables contained within quotes are always evaluated.
set var1 HyperWorks;
puts "$var1 uses Tcl and Tk";
HyperWorks uses Tcl and Tk
Since quotes do not have a right and a left, it is not possible to embed quotes within quotes directly. In the example below, HyperWorks Desktop interprets the quotes between "uses" and "tcl" as being the end quotes:
set var1 HyperWorks;
puts "$ HyperWorks uses "Tcl and Tk"";
extra characters after close-quote
Variables contained within braces are not evaluated.
set var1 HyperWorks;
puts {$var1 uses Tcl and Tk};
$var1 uses Tcl and Tk
Braces are very handy for program control. For example, you define a Tcl/Tk button that calls the command puts $var1 to return the most recent value of var1 when the button is pressed. The parameter for the button command will be {puts $var1} because you don’t want Tcl to evaluate $var1 when the button is defined, but instead when the button is pressed.
Square brackets run the commands contained within them.
set var1 HyperWorks;
set var2 [set var1];
puts $var2;
HyperWorks