OSF DCE Administration Guide--Core Components

OSF DCE Administration Guide—Core Components
section for readability. This section consists of one or more conversion specifiers
delimited by % (percent sign). Conversion specifiers define which parts of string get
converted and stored, as well as the type of conversion.
The following example parses the string contained in the variable _dcp_temp for a valid
floating-point number and stores it in the variable _dcp_temp2:
if { [scan $_dcp_temp "%f" _dcp_temp2] !=1}{
error "Variable \"$_dcp_temp\" is not a \
valid floating-point number"
}
2.13.3 Other String Handling Operations
You can specify one character or a range of characters in a string by using string index
and string range. These commands would be useful for extracting information from a
string of predictable length.
The string index command has one argument that is the position of one character
(counting from left to right beginning with 0 (zero) to be extracted from the string. The
string range command includes two arguments that are the positions of the leftmost and
rightmost characters to be included in the range. The following example illustrates one
use of the string range command:
dcecp> string range {The quick brown fox} 4 9
quick
dcecp>
You can determine whether one string is lexicographically (alphabetically) greater than,
less than, or equal to another string by using string compare. Generally, this operation
performs a byte comparison of ASCII codes that make up the string.
Count the number of characters in a string using the string length command. Here is an
example:
dcecp> string length "The quick brown fox"
19
dcecp>
Convert characters between uppercase and lowercase by using the string toupper and
string tolower commands. Here is an example:
dcecp> string toupper "The quick brown fox"
THE QUICK BROWN FOX
dcecp>
Trim specific characters from a string by using the string trim command. Remove the
leftmost or rightmost characters from a string by using the string trimleft and string
trimright commands.
2 28 Tandem Computers Incorporated 124243