-
Book Overview & Buying
-
Table Of Contents
Tcl/Tk 8.5 Programming Cookbook
Now that we have mapped, formatted, counted, analyzed, and generally picked our strings apart, let's look at programmatically performing variable substitution in a string. As Tcl always seems to do, we have been provided with a powerful command to simplify the task with the subst command. While you could easily invoke the set command to change the contents, subst provides the ability to alter portions of a variable by providing optional switches.
The syntax of the subst command is as follows:
subst switch string
The subst command performs variable substitution to a string. The behavior may be controlled with optional switches.
These switches are as follows:
|
Switch |
Description |
|---|---|
|
|
No backslash substitution will be performed. |
|
|
No command substitution will be performed. |
|
|
No variable substitution will be performed. |
In the following example, we will create a string that contains the value of a variable...
Change the font size
Change margin width
Change background colour