Rough Cuts are manuscripts that are developed but not yet published, available through Safari. Rough Cuts provide you access to the very latest information on a given topic and offer you the opportunity to interact with the author to influence the final publication.
Also available in other formats.
This is a working draft of a pre-release book. It is available before the published date as part of the Rough Cuts service.
John K. Ousterhout’s Definitive Introduction to Tcl/Tk–Now Fully Updated for Tcl/Tk 8.5
Tcl and the Tk Toolkit, Second Edition, is the fastest way for newcomers to master Tcl/Tk and is the most authoritative resource for experienced programmers seeking to gain from Tcl/Tk 8.5’s powerful enhancements. Written by Tcl/Tk creator John K. Ousterhout and top Tcl/Tk trainer Ken Jones, this updated volume provides the same extraordinary clarity and careful organization that made the first edition the world’s number one Tcl/Tk tutorial.
Part I introduces Tcl/Tk through simple scripts that demonstrate its value and offer a flavor of the Tcl/Tk scripting experience. The authors then present detailed, practical guidance on every feature necessary to build effective, efficient production applications–including variables, expressions, strings, lists, dictionaries, control flow, procedures, namespaces, file and directory management, interprocess communication, error and exception handling, creating and using libraries, and more.
Part II turns to the Tk extension and Tk 8.5’s new themed widgets, showing how to organize sophisticated user interface elements into modern GUI applications for Tcl.
Part III presents incomparable coverage of Tcl’s C functions, which are used to create new commands and packages and to integrate Tcl with existing C software–thereby leveraging Tcl’s simplicity while accessing C libraries or executing performance-intensive tasks.
Throughout, the authors illuminate all of Tcl/Tk 8.5’s newest, most powerful improvements. You’ll learn how to use new Starkits and Starpacks to distribute run-time environments and applications through a single file; how to take full advantage of the new virtual file system support to treat entities such as zip archives and HTTP sites as mountable file systems; and more.
From basic syntax to simple Tcl commands, user interface development to C integration, this fully updated classic covers it all. Whether you’re using Tcl/Tk to automate system/network administration, streamline testing, control hardware, or even build desktop or Web applications, this is the one Tcl/Tk book you’ll always turn to for answers.
Preface to the First Edition xxvii
PART I: The Tcl Language 1
Chapter 1: An Overview of Tcl and Tk 3
1.1: Getting Started 3
1.2: “Hello, World!” with Tk 6
1.3: Script Files 8
1.4: Variables and Substitutions 11
1.5: Control Structures 12
1.6: On the Tcl Language 14
1.7: Event Bindings 15
1.8: Additional Features of Tcl and Tk 19
Chapter 2: Tcl Language Syntax 21
2.1: Scripts, Commands, and Words 21
2.2: Evaluating a Command 22
2.3: Variable Substitution 24
2.4: Command Substitution 26
2.5: Backslash Substitution 26
2.6: Quoting with Double Quotes 28
2.7: Quoting with Braces 29
2.8: Argument Expansion 30
2.9: Comments 32
2.10: Normal and Exceptional Returns 35
2.11: More on Substitutions 36
Chapter 3: Variables 39
3.1: Commands Presented in This Chapter 39
3.2: Simple Variables and the set Command 41
3.3: Tcl’s Internal Storage of Data 41
3.4: Arrays 42
3.5: Variable Substitution 43
3.6: Multidimensional Arrays 45
3.7: Querying the Elements of an Array 46
3.8: The incr and append Commands 47
3.9: Removing Variables: unset and array unset 49
3.10: Predefined Variables 49
3.11: Preview of Other Variable Facilities 50
Chapter 4: Expressions 53
4.1: Commands Presented in This Chapter 53
4.2: Numeric Operands 54
4.3: Operators and Precedence 55
4.4: Math Functions 58
4.5: Substitutions 60
4.6: String Manipulation 62
4.7: List Manipulation 63
4.8: Types and Conversions 63
4.9: Precision 64
Chapter 5: String Manipulation 65
5.1: Commands Presented in This Chapter 65
5.2: Extracting Characters: string index and string range 69
5.3: Length, Case Conversion, Trimming, and Repeating 70
5.4: Simple Searching 70
5.5: String Comparisons 71
5.6: String Replacements 72
5.7: Determining String Types 73
5.8: Generating Strings with format 74
5.9: Parsing Strings with scan 76
5.10: Glob-Style Pattern Matching 78
5.11: Pattern Matching with Regular Expressions 79
5.12: Using Regular Expressions for Substitutions 87
5.13: Character Set Issues 89