www.gibmonks.com

  Previous section   Next section

Practical Programming in Tcl & Tk, Third Edition
By Brent B. Welch

Table of Contents


List of Examples

1.1 The "Hello, World!" example

1.2 Tcl variables

1.3 Command substitution

1.4 Simple arithmetic

1.5 Nested commands

1.6 Built-in math functions

1.7 Grouping expressions with braces

1.8 Quoting special characters with backslash

1.9 Continuing long lines with backslashes

1.10 Grouping with double quotes vs. braces

1.11 Embedded command and variable substitution

1.12 Defining a procedure

1.13 A while loop to compute factorial

1.14 A recursive definition of factorial

1.15 Using set to return a variable value

1.16 Embedded variable references

1.17 Using info to determine if a variable exists

1.18 Controlling precision with tcl_precision

2.1 A standalone Tcl script on UNIX

2.2 A standalone Tk script on UNIX

2.3 Using /bin/sh to run a Tcl script

2.4 The EchoArgs script

3.1 A simple CGI script

3.2 Output of Example 3-1

3.3 The guestbook.cgi script

3.4 The Cgi_Header procedure

3.5 The Link command formats a hypertext link

3.6 Initial output of guestbook.cgi

3.7 Output of guestbook.cgi

3.8 The newguest.html form

3.9 The newguest.cgi script

4.1 Comparing strings with string compare

4.2 Comparing strings with string equal

4.3 Mapping Microsoft World special characters to ASCII

5.1 Constructing a list with the list command

5.2 Using lappend to add elements to a list

5.3 Using concat to splice lists together

5.4 Double quotes compared to the concat and list commands

5.5 Modifying lists with linsert and lreplace

5.6 Deleting a list element by value

5.7 Sorting a list using a comparison function

5.8 Use split to turn input data into Tcl lists

5.9 Implementing join in Tcl

6.1 A conditional if then else command

6.2 Chained conditional with elseif

6.3 Using switch for an exact match

6.4 Using switch with substitutions in the patterns

6.5 A switch with "fall through" cases

6.6 Comments in switch commands

6.7 A while loop to read standard input

6.8 Looping with foreach

6.9 Parsing command-line arguments

6.10 Using list with foreach

6.11 Multiple loop variables with foreach

6.12 Multiple value lists with foreach

6.13 A for loop

6.14 A standard catch phrase

6.15 A longer catch phrase

6.16 There are several possible return values from catch

6.17 Raising an error

6.18 Preserving errorInfo when calling error

6.19 Raising an error with return

7.1 Default parameter values

7.2 Variable number of arguments

7.3 Variable scope and Tcl procedures

7.4 A random number generator.

7.5 Print variable by name

7.6 Improved incr procedure

8.1 Using arrays

8.2 Referencing an array indirectly

8.3 Referencing an array indirectly using upvar

8.4 ArrayInvert inverts an array

8.5 Using arrays for records, version 1

8.6 Using arrays for records, version 2

8.7 Using a list to implement a stack

8.8 Using an array to implement a stack

8.9 A list of arrays

8.10 A list of arrays

8.11 A simple in-memory database

9.1 Using exec on a process pipeline

9.2 Comparing file modify times

9.3 Determining whether pathnames reference the same file

9.4 Opening a file for writing

9.5 A more careful use of open

9.6 Opening a process pipeline

9.7 Prompting for input

9.8 A read loop using gets

9.9 A read loop using read and split

9.10 Copy a file and translate to native format

9.11 Finding a file by name

9.12 Printing environment variable values

10.1 Using list to construct commands

10.2 Generating procedures dynamically with a template

10.3 Using eval with $args

10.4 lassign: list assignment with foreach

10.5 The File_Process procedure applies a command to each line of a file

11.1 Expanded regular expressions allow comments

11.2 Using regular expressions to parse a string

11.3 A pattern to match URLs

11.4 An advanced regular expression to match URLs

11.5 The Url_Decode procedure

11.6 The Cgi_Parse and Cgi_Value procedures

11.7 Cgi_Parse and Cgi_Value store query data in the cgi array

11.8 Html_DecodeEntity

11.9 Html_Parse

12.1 Maintaining a tclIndex file

12.2 Loading a tclIndex file

13.1 Calculating clicks per second

13.2 Printing a procedure definition

13.3 Mapping form data onto procedure arguments

13.4 Finding built-in commands

13.5 Getting a trace of the Tcl call stack

13.6 A procedure to read and evaluate commands

13.7 Using info script to find related files

13.8 Tracing variables

13.9 Creating array elements with array traces

13.10 Interactive history usage

13.11 Implementing special history syntax

13.12 A Debug procedure

13.13 Time Stamps in log records

14.1 Random number generator using namespaces

14.2 Random number generator using qualified names

14.3 Nested namespaces

14.4 The code procedure to wrap callbacks

14.5 Listing commands defined by a namespace

15.1 MIME character sets.and file encodings

15.2 Using scripts in nonstandard encodings

15.3 Three sample message catalog files

15.4 Using msgcat::mcunknown to share message catalogs

16.1 A read event file handler

16.2 Using vwait to activate the event loop

16.3 A read event file handler for a nonblocking channel

17.1 Opening a client socket with a timeout

17.2 Opening a server socket

17.3 The echo service

17.4 A client of the echo service

17.5 Opening a connection to an HTTP server

17.6 Opening a connection to an HTTP server

17.7 Http_Head validates a URL

17.8 Using Http_Head

17.9 Http_Get fetches the contents of a URL

17.10 HttpGetText reads text URLs

17.11 HttpCopyDone is used with fcopy

17.12 Downloading files with http::geturl

17.13 Basic Authentication using http::geturl

18.1 A simple URL domain

18.2 Application Direct URLs

18.3 Alternate types for Application Direct URLs

18.4 A sample document type handler

18.5 A one-level site structure

18.6 A HTML + Tcl template file

18.7 SitePage template procedure

18.8 SiteMenu and SiteFooter template procedures

18.9 The SiteLink procedure

18.10 Mail form results with /mail/forminfo

18.11 Mail message sent by /mail/forminfo

18.12 Processing mail sent by /mail/forminfo

18.13 A self-checking form procedure

18.14 A page with a self-checking form

18.15 The /debug/source application-direct URL implementation

19.1 Creating and deleting an interpreter

19.2 Creating a hierarchy of interpreters

19.3 A command alias for exit

19.4 Querying aliases

19.5 Dumping aliases as Tcl commands

19.6 Substitutions and hidden commands

19.7 Opening a file for an unsafe interpreter

19.8 The Safesock security policy

19.9 The Tempfile security policy

19.10 Restricted puts using hidden commands

19.11 A safe after command

21.1 "Hello, World!" Tk program.

21.2 Looking at all widget attributes

22.1 Logging the output of a program run with exec

22.2 A platform-specific cancel event

22.3 A browser for the code examples in the book

22.4 A Tcl shell in a text widget

22.5 Macintosh look and feel

22.6 Windows look and feel

22.7 UNIX look and feel

23.1 Two frames packed inside the main frame

23.2 Turning off geometry propagation

23.3 A horizontal stack inside a vertical stack

23.4 Even more nesting of horizontal and vertical stacks

23.5 Mixing bottom and right packing sides

23.6 Filling the display into extra packing space

23.7 Using horizontal fill in a menu bar

23.8 The effects of internal padding (-ipady)

23.9 Button padding vs. packer padding

23.10 The look of a default button

23.11 Resizing without the expand option

23.12 Resizing with expand turned on

23.13 More than one expanding widget

23.14 Setup for anchor experiments

23.15 The effects of noncenter anchors

23.16 Animating the packing anchors

23.17 Controlling the packing order

23.18 Packing into other relatives

24.1 A basic grid

24.2 A grid with sticky settings

24.3 A grid with row and column specifications

24.4 A grid with external padding

24.5 A grid with internal padding

24.6 All combinations of -sticky settings

24.7 Explicit row and column span

24.8 Grid syntax row and column span

24.9 Row padding compared to widget padding

24.10 Gridding a text widget and scrollbar

25.1 Centering a window with place

25.2 Covering a window with place

25.3 Combining relative and absolute sizes

25.4 Positioning a window above a sibling with place

25.5 Pane_Create sets up vertical or horizontal panes

25.6 PaneDrag adjusts the percentage

25.7 PaneGeometry updates the layout

26.1 Bindings on different binding tags

26.2 Output from the UNIX xmodmap program

26.3 Emacs-like binding convention for Meta and Escape

26.4 Virtual events for cut, copy, and paste

27.1 A troublesome button command

27.2 Fixing the troublesome situation

27.3 A button associated with a Tcl procedure

27.4 Radiobuttons and checkbuttons

27.5 A command on a radiobutton or checkbutton

27.6 A menu sampler

27.7 A menu bar in Tk 8.0

27.8 A simple menu by name package

27.9 Using the Tk 8.0 menu bar facility

27.10 MenuGet maps from name to menu

27.11 Adding menu entries

27.12 A wrapper for cascade entries

27.13 Using the menu by name package

27.14 Keeping the accelerator display up to date

28.1 Reading an option database file

28.2 A file containing resource specifications

28.3 Using resources to specify user-defined buttons

28.4 Resource_ButtonFrame defines buttons based on resources

28.5 Using Resource_ButtonFrame

28.6 Specifying menu entries via resources

28.7 Defining menus from resource specifications

28.8 Resource_GetFamily merges user and application resources

29.1 Macintosh window styles

29.2 A label that displays different strings

29.3 The message widget formats long lines of text

29.4 Controlling the text layout in a message widget

29.5 A scale widget

30.1 A text widget and two scrollbars

30.2 Scroll_Set manages optional scrollbars

30.3 Listbox with optional scrollbars

31.1 A command entry

32.1 Choosing items from a listbox

33.1 Tag configurations for basic character styles

33.2 Line spacing and justification in the text widget

33.3 An active text button

33.4 Delayed creation of embedded widgets

33.5 Using embedded images for a bulleted list

33.6 Finding the current range of a text tag

33.7 Dumping the text widget

33.8 Dumping the text widget with a command callback

34.1 A large scrolling canvas

34.2 The canvas "Hello, World!" example

34.3 A min max scale canvas example

34.4 Moving the markers for the min max scale

34.5 Canvas arc items

34.6 Canvas bitmap items

34.7 Canvas image items

34.8 A canvas stroke drawing example

34.9 Canvas oval items

34.10 Canvas polygon items

34.11 Dragging out a box

34.12 Simple edit bindings for canvas text items

34.13 Using a canvas to scroll a set of widgets

34.14 Generating postscript from a canvas

35.1 Paste the PRIMARY or CLIPBOARD selection

35.2 Separate paste actions

35.3 Bindings for canvas selection

35.4 Selecting objects

35.5 A canvas selection handler

35.6 The copy and cut operations

35.7 Pasting onto the canvas

36.1 Procedures to help build dialogs

36.2 A simple dialog

36.3 A feedback procedure

37.1 Equal-sized labels

37.2 3D relief sampler

37.3 Padding provided by labels and buttons

37.4 Anchoring text in a label or button

37.5 Borders and padding

38.1 Resources for reverse video

38.2 Computing a darker color

38.3 Specifying an image for a widget

38.4 Specifying a bitmap for a widget

38.5 The built-in bitmaps

38.6 The Tk cursors

39.1 The FontWidget procedure handles missing fonts

39.2 Font metrics

39.3 A gridded, resizable listbox

39.4 Font selection dialog

40.1 The sender application

40.2 Hooking the browser to an eval server

40.3 Making the shell into an eval server

40.4 Remote eval using sockets

40.5 Reading commands from a socket

40.6 The client side of remote evaluation

41.1 Gridded geometry for a canvas

41.2 Telling other applications what your name is

42.1 Preferences initialization

42.2 Adding preference items

42.3 Setting preference variables

42.4 Using the preferences package

42.5 A user interface to the preference items

42.6 Interface objects for different preference types

42.7 Displaying the help text for an item

42.8 Saving preferences settings to a file

42.9 Read settings from the preferences file

42.10 Tracing a Tcl variable in a preference item

43.1 A user interface to widget bindings

43.2 Bind_Display presents the bindings for a widget or class

43.3 Related listboxes are configured to select items together

43.4 Controlling a pair of listboxes with one scrollbar

43.5 Drag-scrolling a pair of listboxes together

43.6 An interface to define bindings

43.7 Defining and saving bindings

44.1 The initialization procedure for a loadable package

44.2 The RandomCmd C command procedure

44.3 The RandomObjCmd C command procedure

44.4 The Tcl_Obj structure

44.5 The Plus1ObjCmd procedure

44.6 The Blob and BlobState data structures

44.7 The Blob_Init and BlobCleanup procedures

44.8 The BlobCmd command procedure

44.9 BlobCreate and BlobDelete

44.10 The BlobNames procedure

44.11 The BlobN and BlobData procedures

44.12 The BlobCommand and BlobPoke procedures

44.13 A canonical Tcl main program and Tcl_AppInit

44.14 A canonical Tk main program and Tk_AppInit

44.15 Calling C command procedure directly with Tcl_Invoke

46.1 The Clock_Init procedure

46.2 The Clock widget data structure

46.3 The ClockCmd command procedure

46.4 The ClockObjCmd command procedure

46.5 The ClockInstanceCmd command procedure

46.6 The ClockInstanceObjCmd command procedure

46.7 ClockConfigure allocates resources for the widget

46.8 ClockObjConfigure allocates resources for the widget

46.9 The Tk_ConfigSpec typedef

46.10 Configuration specs for the clock widget

46.11 The Tk_OptionSpec typedef

46.12 The Tk_OptionSpec structure for the clock widget

46.13 ComputeGeometry computes the widget's size

46.14 The ClockDisplay procedure

46.15 The ClockEventPro handles window events

46.16 The ClockDestroy cleanup procedure

46.17 The ClockObjDelete command


      Previous section   Next section
    Top