-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Tcl/Tk 8.5 Programming Cookbook
Strings, as we all know, are our primary way of interacting with the end user. Whether presented in a message box or simply directed to the Tcl shell, they need to be as fluid as possible, in the values they present. To accomplish this, Tcl provides the format command. This command allows us to format a string with variable substitution in the same manner as the ANSI C sprintf procedure. The format command is as follows:
format string argument argument argument…
The format command accepts a string containing the value to be formatted as well as % conversion specifiers. The arguments contain the values to be substituted into the final string. Each conversion specifier may contain up to six sections—an XPG2 position specifier, a set of flags, minimum field width, a numeric precision specifier, size modifier, and a conversion character. The conversion specifiers are as follows:
|
Specifier |
Description |
|---|---|
|
|
For converting an integer to a signed decimal string. |
|
|
Change the font size
Change margin width
Change background colour