Version 1 of examples needed

Updated 2004-04-16 13:03:35

It would be nice to see at least a simple example included for all Tcl man pages (or at the very least point to another page including an example).

Here is the current state of things:

Files with examples: array.n catch.n encoding.n fcopy.n fileevent.n foreach.n http.n lassign.n lindex.n lrepeat.n lsearch.n lset.n lsort.n return.n socket.n subst.n

Files without examples: Tcl.n after.n append.n bgerror.n binary.n break.n case.n cd.n clock.n close.n concat.n continue.n dde.n dict.n eof.n error.n eval.n exec.n exit.n expr.n fblocked.n fconfigure.n file.n filename.n flush.n for.n format.n glob.n global.n history.n if.n incr.n info.n interp.n join.n lappend.n library.n linsert.n list.n llength.n load.n lrange.n lreplace.n memory.n msgcat.n namespace.n open.n package.n packagens.n pid.n pkgMkIndex.n proc.n puts.n pwd.n re_syntax.n read.n regexp.n registry.n regsub.n rename.n safe.n scan.n seek.n set.n source.n split.n string.n switch.n tcltest.n tclvars.n tell.n time.n trace.n unknown.n unload.n unset.n update.n uplevel.n upvar.n variable.n vwait.n while.n

Adding an example doesn't take much time, and lots are already available on the wiki. All you have to do is submit a patch to sourceforge. The man page markup looks like this:

 .SH "EXAMPLES"

 A time server:

 .CS
 proc Server { channel clientaddr clientport } {
     puts "Connection from $clientaddr registered"
     puts $channel [clock format [clock seconds]]
     close $channel
 }

 socket -server Server 9900
 vwait forever
 .CE

I used this code to check:

 package require fileutil
 package require struct

 foreach res [fileutil::grep ".SH.*EXAMPLE" [glob *.n]] {
     lappend examplefiles [lindex [split $res :] 0]
 }
 set examplefiles [lsort $examplefiles]

 set allfiles [lsort [glob *.n]]
 set noexamplefiles [lsort [struct::set difference $allfiles $examplefiles]]

 puts "Files with examples: $examplefiles"
 puts ""
 puts "Files without examples: $noexamplefiles"