Errata for 2nd Edition

Practical Programming in Tcl and Tk
ISBN: 0-13-616830

This page reflects errors that were found in the first printing and fixed for the second printing. Of course, the day after I gave the fixes to the publisher I found more errors.

Book Home Page

Last update Mon Jun 29 21:54:14 PDT 1998

Back Cover

coverThe URL on the back of the book is wrong! It should be

Chapter 1

p19Missing rand() and srand(seed) math functions
pp21-22Missing namespace, package, and variable commands

Chapter 2

pp23-24Should cross reference the CGI script from Chapter 3.
p27Line-wrap bug at top of page.
p28browser_args is changing (back) to embed_args.
p28The browser_args variable was renamed embed_args to be compatible with the 1.0 version of the plugin.

Chapter 3

p33Line-wrap bug at bottom of page.
p36Typo: "show" should be "shown" at bottom of page.
p37Should reference Example 3-8 explicitly
p41Added reference to Libes' cgi.tcl package

Chapter 4

p45Font error in "append is efficient"
p51Font error in "@" at bottom of page
p51The sentence at the bottom of the page should be "This command gets the second double-precision number." (not the third.)
p52Should say "binary format", not "scan format"
p52Reference to Chapter 47 is bogus.

Chapter 5

p54-glob switch broken across lines in Table 5-1.

Chapter 6

p67At end of page, should say "once for each element in the list" (not loop)
p70Bad line break in Example 6-12

Chapter 8

p88Should be "return $employeeManager($name)" in Example 8-5
p88Should be "return $employee(manager,$name)" in Example 8-6

Chapter 9

p93Added reference to AppleScript documentation
p99Delete extra reference to Table 9-3
p100-permissions file attribute can only be a number. The symbolic modes understood by the UNIX chmod program are not supported.
p103Fixed reference to Exploring Expect, and removed "do" from "... powerful way to do interact ..."
p106Font error on glob at bottom of page.
p109I added a note about defining environment variables on the Macintosh
Note: Environment variables can be initialized for Macintosh applications by editing a resource of type STR# whose name is "Tcl Environment Variables". This resource is part of the tclsh and wish applications. Follow the directions on page 26 for using ResEdit. The format of the resource values is NAME=VALUE.

Chapter 11

p126Fixed reference to Table 11-2 from "these tables".
p126Added another example pattern, "(^|\n)to:\[^\n\]+\n"
p128"URl" should be "URL".

Chapter 13

p156Note added: history substitute and words operations were removed in Tcl 8.0
p163Fixed citation of Tcl/Tk Tools (Mark Harrison, ed. O'Reilly & Associates, Inc., 1997)

Chapter 14

p166,167,168,171namespace commands need eval keyword
p172First entry in Table 14-1 is not valid. You must use the eval keyword

Chapter 15

p178after info takes an optional "id" argument and returns the command for that after event.
p182Bad break after - in -buffersize at end of page.
p183Fixed reference to Table 15-4.
p184Removed first sentence on the page about leaving off parts of the mode value - you need to supply all four parts.

Chapter 16

p186Added reference to Scotty.
p186Fixed bad line wrap in sample socket command.
p190Fixed bad line wrap in Example 16-4.
p191Fixed bad line wrap in Example 16-5.
p193Changed Http_Header to HttpHeader.
p194Http_Get has a broken regsub pattern. It should use
 regsub "HTTP/1.. " $header(http) {} header(http)
p196Fixed bad line wrap in Example 16-10.
p197Fixed font for input output in fcopy example.
p197Added sample fcopy callback procedure
proc CopyDone {in out bytes {error {}} {
	close $in ; close $out
p201Added description of http 2.0 package, which uses the ::http namespace. The procedures in the package are:

Chapter 17

p207vwait should be removed from Table 17-2
p213The safe base was completely re-written to use the ::safe namespace and to eliminate the package require facility that loads security policies. The new interface to the safe base is:
     ::safe::interpCreate ?slave? ?options...?
     ::safe::interpInit slave ?options...?
     ::safe::interpConfigure slave ?options...?
     ::safe::interpDelete slave
     ::safe::interpAddToAccessPath slave directory
     ::safe::interpFindInAccessPath slave directory
     ::safe::setLogCmd ?cmd arg...?
The options to interpCreate, interpInit, and interpConfigure are:
     -accessPath pathList
     -deleteHook script
The slave aliases also include a file alias that allows the dirname, join, extension, root, tail, pathname, and split operations.
p215Bad line breaks in example 17-8.
p216Fixed reference to Example 17-10 (was "x").
p218Font error for tempfile(directory) at top of page.
p219Font error for after at top of page.
p221SafeAfterExitAlias should be:
proc SafeAfterExitAlias {slave} {
	global after
	foreach id [array names after id,$slave,*] {
		after cancel $after($id)
		unset after($id)
	interp delete $slave

Chapter 18

p229Bad line break in Example 18-2
p232"resources" should be "resource" in the option entry for Table 18-2

Chapter 19

p241Bad line break near the bottom of the page.
p245Fix reference to Example 37-2 on page 481
p246In EvalTypein, the newline should be inserted before the text is fetched from the text widget. It should read:
proc EvalTypein {} {
	global eval
	$eval(text) insert insert \n
	set command [$eval(text) get limit end]
	if [info complete $command] {
		$eval(text) mark set limit insert
		Eval $command

Chapter 21

p267Chapter info text should read "...that positions widgets on a grid that..."
p274The bbox entry in Table 21-1 should read
grid bbox master ?c1 r1? ?c2 r2?
The column number comes before the row number.
p274The boolean argument to the propagate operation is optional.
p274The slaves table entry has an extra period after "win", and a bad line break after a hypen.

Chapter 22

p282Bad line break in Example 22-7 in $pane(-percent)

Chapter 23

p297"lists" should be "listed" in the last entry of Table 23-3

Chapter 24

p310The -default attribute has three possible values: active, disabled, or normal. active displays as a default button. normal and disabled display as a normal button.
p311The -relief attribute can also be solid.
p313Example 24-6 should use -value attributes for the radio buttons (e.g., -value apple)
p314Font error for .menubar in System Menus paragraph.
p314The last sentence should end " is an option menu."
p315"indicate" should be "indicated" near top of page
p318In the menu by name package, the global array is menu, not Menu.

Chapter 25

p325userdDefault should be userDefault
p330The radio branch of the switch statement in Example 25-7 should supply a -value $l
p332WindowMenuInner should be a recursive call to ResourceMenu in the new ResourceMenu definition.

Chapter 26

p334The -relief attribute can also be solid.
p338The -relief attribute can also be solid.
p340The -relief attribute can also be solid.
p342The -relief attribute can also be solid.

Chapter 27

p347Repeated "a" in the middle of the page.
p348Bad page breaks after -sticky in Example 27-3.

Chapter 28

p356The -relief attribute can also be solid.

Chapter 29

p361Bad line break at top of page.
p367The -relief attribute can also be solid.

Chapter 30

p371Font error for delete in 2nd paragraph.
p374The -relief attribute can also be solid.
p374Bad line break after hypen in -offset.
p382"that" should be "than" in first paragraph.

Chapter 31

p391The first word, "This", should be "The"
p407Font error for index in 4th entry of Table 31-9.
p410Bad line breaks in Example 31-12 after rootx and rooty
p410The -width attribute of canvas text items controls how big they get before they are wrapped.
p414"postscript out" should be "postscript output" in the only paragraph.
p417First column of Table 31-13 should be 10pc (not 9pc) wide to avoid breaking highlightBackground.
p417The -relief attribute can also be solid.
p417Font error for "canvas" in scrollRegion entry of Table 31-13.
p417Put a semi-colon after "totally off the scroll region"

Chapter 32

p423Throughout Part V, the Chapter banner is incorrectly formatted. The C H A P T E R is too low because its table cell should be middle aligned, not bottom aligned.
p423Delete "the" before "Macintosh and Windows" in last paragraph.
p426Table 32-2 should have TBleft formatting in the left column.
p431The Chapter banner is incorrectly formatted.
p441Font error for update idletasks in last paragraph.

Chapter 34

p443The Chapter banner is incorrectly formatted.
p447The activeBorderWidth and activeRelief attributes only have effect on UNIX.
p449The anchor value for .f.two should be nw, not w, in Example 34-5.

Chapter 35

p451The Chapter banner is incorrectly formatted.
p452The activeForeground entry is missing a period after "widget".
p452The disabledForeground entry has a font error on "and".
p457There is a font error for "-visual" in the first sentence.
p460The -channel option listed in Table 35-7 for photo widgets does not exist. It was just wishful thinking on my part.
p461The right-hand column of Table 35-9 is in the wrong font. Should be TB paragraph type.

Chapter 36

p465The Chapter banner is incorrectly formatted.
p469Bad line break in Example 36-1
p469Re-worded Font Failures opening paragraph to start
Unfortunately, if a font is missing, versions of Tk before 8.0 do not attempt to substitute another font, not even fixed. (Tk 8.0 only does substitutions if you use platform-independent font names.) Before Tk 8.0, the widget creation or reconfiguration command raises an error if the font does not exist.
p471Font error for "font" in font measure and font metrics entries of Table 36-3
p472The hot tip icon is on the wrong side of the page.

Chapter 37

p477The Chapter banner is incorrectly formatted.
p482Two periods after browser.
p483The append command should be
append eval(cmdbuf,$sock) $line\n
in Example 37-5
p484Font error for return in last paragraph.

Chapter 38

p487The Chapter banner is incorrectly formatted.
p491Font error for "and" in first entry of Table 38-3.
p491Format error for left column of Table 38-3, should be TBleft.
p495Delete sentence: "This value is useful in the selection command."
p497The embedding example should use -containter:
frame .embed -container true
p498Table 38-11 has a font error for "win" in the winfo visual entry.
p498Added note that tk scale was added in Tk 8.0.

Chapter 39

p499The Chapter banner is incorrectly formatted.
p501There is a much cleaner and more reliable way to set preference items in Example 39-2 using the switch statement:
    switch -regexp -- $default {
	    ^CHOICE {
		    PrefValueSet $varName [lindex $default 1]
	    ^OFF {
		    PrefValueSet $varName 0
	    ^ON {
		    PrefValueSet $varName 1
	    default {
		    # This is a string or numeric
		    PrefValueSet $varName $default

Chapter 40

p511The Chapter banner is incorrectly formatted.

Chapter 41

p521The Chapter banner is incorrectly formatted.
p530The second paragraph was re-written because the initial reference count of an object is now zero, not one. It reads
The Tcl_NewTypeObj allocates storage for an object and sets its reference count to zero. Tcl_IncrRefCount and Tcl_DecrRefCount increment and decrement the reference count on an object. Tcl_DecrRefCount frees the storage for an object when it goes to zero. The initial reference count of zero was chosen because functions like Tcl_SetObjResult automatically increment the reference count on an object.
p531The * in the "Assert..." comment block are not lined up right.
p535Missing a tab before (char *) &myoption near top of page.
p536Bad line break in the comment inside Example 41-8.
p539All occurrences of if (object) should be
if (info.isNativeObjectProc)
Bad line break in the comment inside Example 41-8. Here is a pointer to a cleaned up version of Tcl_Invoke, due to Jean Brouwers.
p539All occurrences of if (object) should be
if (info.isNativeObjectProc)
And this should be added after the Tcl_NewStringObj statement:
p540All occurrences of if (object) should be
if (info.isNativeObjectProc)
After invoking the (*info.objProc), the two statements that set the string result can be replaced with this simpler call:
p544First sentence of 2nd paragraph should contain \"used to build\".
p545Bad line breaks in Example 41-12
p547Bad line break in Example 41-13 on ${SHLIB_LD} command
p548The reference to the examples/C directory should instead be examples/cprog. There is also another example on the CD-ROM in examples/build.

Chapter 42

p549The Chapter banner is incorrectly formatted.
p551There are font errors for alloc, realloc, and free in the Memory Allocation section.
p553Delete reference to tcl_precision, which no longer exists.
p553Font error for "Object" in the Tcl Objects section.
p554Font error for "Strings support" in the Primitive Object Types section.
p559Font error for "TkInit" in the Creating Windows section.

Chapter 43

p567The Chapter banner is incorrectly formatted.
p569Delete duplicate ckalloc line in Example 43-2.
p570Should save the result of Tcl_CreateCommand for use when deleting the command later.
clockPtr->widgetCmd = Tcl_CreateCommand(interp,
	(ClientData) clockPtr, (void (*)()) NULL);
p579Use Tcl_DeleteCommandFromToken to handle the case where the command has been renamed.

Chapter 44

p585The Chapter banner is incorrectly formatted.

Chapter 45

p593The Chapter banner is incorrectly formatted.

Chapter 46

p597The Chapter banner is incorrectly formatted.

Chapter 47

p599The Chapter banner is incorrectly formatted.
p599Typeset all of the first word, "Tcl" in body.initialCap font.
p599Delete the word "featured" in first paragraph.
p601The Safe-Tcl section should no longer talk about configurable security policies. That function has moved into the Web Browser plug-in. Instead, it now mentions the safe base:
Initialization of a safe interpreter with a safe base that supports auto loading and a standard exit alias has been abstracted into a Tcl interface. The safe::interpCreate and safe::interpInit procedures create or initialize a slave with the safe base. The safe::interpDelete procedure cleans up. The safe base is described on page 212.
p601Font error for "clock" in the Year 2000 section.
p601Change http_get to http::geturl. The page number reference changes to 201.
p603The first sentence should end "CDE look and feel."
p603The last paragraph now reads
This book first went to press after Tcl/Tk 8.0a2, the 2nd alpha release, and just before the first beta release. I tried to document the last major changes to Tcl/Tk 8.0 such as namespaces, binary I/O, and menu enhancements that appeared in the beta and final versions. However, I could not anticipate every change made before Tcl/Tk 8.0 went final. The rest of this section summarizes updates made in the 2nd and later reprints. Please consult for errata and news about Tcl/Tk updates.
p604This formerly blank page now summarizes the main changes that were made to Tcl and Tk after the first printing of the book:

namespace eval

The eval keyword is required when putting code inside namespaces. Other wise there is ambiguity between the other namespace operations (e.g., import) and namespaces with the same name. This affects several of the examples in Chapter 14.

http Package

A 2nd version of the http package was created that uses the ::http namespace. The functionality is the same, but the names of the procedures changed. See page 201.

Safe-Tcl Safe Base

The safe base was completely redone. It uses the ::safe namespace and no longer supports the use of package require to request security policies. See page 212.

Object Reference Counts

The initial reference count of an object is now zero, not one. This affected the implementation of Tcl_Invoke shown in Example 419 on page 538

The Web Browser Plug-in

The plug-in changed a lot. The mechanism to load security policies was shifted from the safe base into the plug-in. Instead of using package require, a new policy command is used by slaves. The set of security policies also changed. As of this printing the plug-in is just going into is 2.0beta2 release. The best doc umentation will probably be on the web at

Chapter 48

p605The Chapter banner is incorrectly formatted.
p606Example 48-1 should use the -container flag:
set embed [frame $rim.child -container true]
This example should use safe::loadTk to correctly load Tk and set up the argv variable for the slave:
::safe::loadTk safetk -use [winfo id $embed]
p607Table 48-1 should not list tkwait, which really is available to slaves.
p608The browser_args variable was renamed embed_args to be compatible with the 1.0 version of the plugin.
pp609-613The rest of this chapter changed substantially because the plug-in implementation change. You might as well look at the on-line version of the chapter.