summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-05-11 09:08:38 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-05-11 09:08:38 (GMT)
commitea67b7c015f69452168105f73dde76533864abd8 (patch)
treea3db4109186369ae6fd2f2ec92464a20a60de449 /doc
parent0a9f409e6dc9ba06b9d197181daef5ee124852b3 (diff)
downloadtcl-ea67b7c015f69452168105f73dde76533864abd8.zip
tcl-ea67b7c015f69452168105f73dde76533864abd8.tar.gz
tcl-ea67b7c015f69452168105f73dde76533864abd8.tar.bz2
Another example and a bit more clarity.
Diffstat (limited to 'doc')
-rw-r--r--doc/scan.n17
1 files changed, 14 insertions, 3 deletions
diff --git a/doc/scan.n b/doc/scan.n
index 4298faf..6892967 100644
--- a/doc/scan.n
+++ b/doc/scan.n
@@ -6,7 +6,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: scan.n,v 1.10 2004/05/10 22:10:35 dkf Exp $
+'\" RCS: @(#) $Id: scan.n,v 1.11 2004/05/11 09:08:49 dkf Exp $
'\"
.so man.macros
.TH scan n 8.4 Tcl "Tcl Built-In Commands"
@@ -208,12 +208,22 @@ modifiers are ignored when converting real values (i.e. type
If the end of the input string is reached before any conversions have been
performed and no variables are given, an empty string is returned.
.SH EXAMPLES
-Parse a \fIHH:MM\fR time string:
+Parse a simple color specification of the form \fI#RRGGBB\fR using
+hexadecimal conversions with field sizes:
+.CS
+set string "#08D03F"
+scan $string "#%2x%2x%2x" r g b
+.CE
+
+Parse a \fIHH:MM\fR time string, noting that this avoids problems with
+octal numbers by forcing interpretation as decimals (if we did not
+care, we would use the \fB%i\fR conversion instead):
.CS
set string "08:08" ;# *Not* octal!
if {[scan $string "%d:%d" hours minutes] != 2} {
error "not a valid time string"
}
+# We have to understand numeric ranges ourselves...
if {$minutes < 0 || $minutes > 59} {
error "invalid number of minutes"
}
@@ -231,7 +241,8 @@ while {[scan $string %s%n word length] == 2} {
}
.CE
-Parse a simple coordinate string, checking that it is complete:
+Parse a simple coordinate string, checking that it is complete by
+looking for the terminating character explicitly:
.CS
set string "(5.2,-4e-2)"
# Note that the spaces before the literal parts of