summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--doc/glob.n28
-rw-r--r--doc/incr.n25
-rw-r--r--doc/set.n28
4 files changed, 75 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 380c20f..d50a32f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
2004-04-30 Donal K. Fellows <donal.k.fellows@man.ac.uk>
- * doc/if.n, doc/rename.n, doc/time.n: More examples.
+ * doc/glob.n, doc/incr.n, doc/set.n: More examples.
+ * doc/if.n, doc/rename.n, doc/time.n:
2004-04-30 Don Porter <dgp@users.sourceforge.net>
diff --git a/doc/glob.n b/doc/glob.n
index c645f8a..01b4a0f 100644
--- a/doc/glob.n
+++ b/doc/glob.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: glob.n,v 1.14 2004/03/17 18:14:12 das Exp $
+'\" RCS: @(#) $Id: glob.n,v 1.15 2004/04/30 22:45:56 dkf Exp $
'\"
.so man.macros
.TH glob n 8.3 Tcl "Tcl Built-In Commands"
@@ -26,7 +26,6 @@ of the \fIpattern\fR arguments.
If the initial arguments to \fBglob\fR start with \fB\-\fR then
they are treated as switches. The following switches are
currently supported:
-.VS 8.3
.TP
\fB\-directory\fR \fIdirectory\fR
Search for files which match the given patterns starting in the given
@@ -39,12 +38,10 @@ whose names may contain glob-sensitive characters.
\fB\-join\fR
The remaining pattern arguments are treated as a single pattern
obtained by joining the arguments with directory separators.
-.VE 8.3
.TP
\fB\-nocomplain\fR
Allows an empty list to be returned without error; without this
switch an error is returned if the result list would be empty.
-.VS 8.3
.TP
\fB\-path\fR \fIpathPrefix\fR
Search for files with the given \fIpathPrefix\fR where the rest of the name
@@ -102,7 +99,6 @@ The following are equivalent:
except that the first case doesn't return the trailing ``/'' and
is more platform independent.
.RE
-.VE 8.3
.TP
\fB\-\|\-\fR
Marks the end of switches. The argument following this one will
@@ -156,7 +152,6 @@ start with a tilde ``~'' (for example through \fBglob *\fR or
``./''. This means care must be taken if those names are later to
be used with \fBfile join\fR, to avoid them being interpreted as
absolute paths pointing to a given user's home directory.
-
.SH "PORTABILITY ISSUES"
.PP
Unlike other Tcl commands that will accept both network and native
@@ -184,6 +179,27 @@ interpreted as a wildcard character. One solution to this problem is
to use the Unix style forward slash as a path separator. Windows style
paths can be converted to Unix style paths with the command \fBfile
join $path\fR (or \fBfile normalize $path\fR in Tcl 8.4).
+.SH EXAMPLES
+Find all the Tcl files in the current directory:
+.CS
+glob *.tcl
+.CE
+
+Find all the Tcl files in the user's home directory, irrespective of
+what the current directory is:
+.CS
+glob \-directory ~ *.tcl
+.CE
+
+Find all subdirectories of the current directory:
+.CS
+glob \-type d *
+.CE
+
+Find all files whose name contains an "a", a "b" or the sequence "cde":
+.CS
+glob \-type f *{a,b,cde}*
+.CE
.SH "SEE ALSO"
file(n)
diff --git a/doc/incr.n b/doc/incr.n
index 68f3114..6a2ecc3 100644
--- a/doc/incr.n
+++ b/doc/incr.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: incr.n,v 1.3 2000/09/07 14:27:48 poenitz Exp $
+'\" RCS: @(#) $Id: incr.n,v 1.4 2004/04/30 22:45:56 dkf Exp $
'\"
.so man.macros
.TH incr n "" Tcl "Tcl Built-In Commands"
@@ -26,6 +26,29 @@ integer) is added to the value of variable \fIvarName\fR; otherwise
1 is added to \fIvarName\fR.
The new value is stored as a decimal string in variable \fIvarName\fR
and also returned as result.
+.SH EXAMPLES
+Add one to the contents of the variable \fIx\fR:
+.CS
+incr x
+.CE
+
+Add 42 to the contents of the variable \fIx\fR:
+.CS
+incr x 42
+.CE
+
+Add the contents of the variable \fIy\fR to the contents of the
+variable \fIx\fR:
+.CS
+incr x $y
+.CE
+
+Add nothing at all to the variable \fIx\fR (often useful for checking
+whether an argument to a procedure is actually numeric and generating
+an error if it is not):
+.CS
+incr x 0
+.CE
.SH "SEE ALSO"
expr(n)
diff --git a/doc/set.n b/doc/set.n
index be48036..c5bc059 100644
--- a/doc/set.n
+++ b/doc/set.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: set.n,v 1.3 2000/09/07 14:27:51 poenitz Exp $
+'\" RCS: @(#) $Id: set.n,v 1.4 2004/04/30 22:45:56 dkf Exp $
'\"
.so man.macros
.TH set n "" Tcl "Tcl Built-In Commands"
@@ -43,6 +43,32 @@ or local variable of the procedure unless the \fBglobal\fR command
was invoked to declare \fIvarName\fR to be global,
or unless a \fBvariable\fR command
was invoked to declare \fIvarName\fR to be a namespace variable.
+.SH EXAMPLES
+Store a random number in the variable \fIr\fR:
+.CS
+set r [expr rand()]
+.CE
+
+Store a short message in an array element:
+.CS
+set anAry(msg) "Hello, World!"
+.CE
+
+Store a short message in an array element specified by a variable:
+.CS
+set elemName "msg"
+set anAry($elemName) "Hello, World!"
+.CE
+
+Copy a value into the variable \fIout\fR from a variable whose name is
+stored in the \fIvbl\fR (note that it is often easier to use arrays in
+practice instead of doing double-dereferencing):
+.CS
+set in0 "small random"
+set in1 "large random"
+set vbl in[expr {rand() >= 0.5}]
+set out [set $vbl]
+.CE
.SH "SEE ALSO"
expr(n), proc(n), trace(n), unset(n)