Constructing Strings
Often, scripts need to construct strings for use in other commands or for displaying on the screen for users. The DCE control program provides a format command that you use to
construct strings for use by your script.
The format command substitutes variables where needed. The following example constructs the variable _dcp_host_entries using the format command to prepend the cell name
string (the string type is indicated by %s) to the string /hosts. The cell name is contained in the _c convenience variable.
dcecp> set _dcp_host_entries [format "%s/hosts" $_c] /.../my_cell.goodco.com/hosts dcecp>
The format command can also convert arguments between differing forms including decimal, octal, hexadecimal, floating point, and scientific notation. You can also specify to print or omit
signs for signed numbers, right- or left- justify output, and padding with spaces or zeros. The following examples convert the integer 8 to its octal equivalent. The second example shifts the
output nine character spaces to the right.
dcecp> format %1o 8 10 dcecp> format %9o 8 10 dcecp>
|