Version 9 of examples needed

Updated 2004-04-22 09:12:39

davidw: 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: after.n array.n bgerror.n catch.n encoding.n fcopy.n fileevent.n foreach.n gets.n http.n lappend.n lassign.n lindex.n linsert.n llength.n lrange.n lrepeat.n lreplace.n lsearch.n lset.n lsort.n read.n return.n socket.n subst.n

Files without examples: Tcl.n append.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 library.n list.n load.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 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


These are automatically generated (script below). Some of these do have examples, such as msgcat and tcltest. Others sort of do, but a functional bit of code that runs and demonstrates the command is always welcome.

Exception List: The list of files that really do have (good) examples: binary.n msgcat.n tcltest.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"

Category Documentation