Produktinformation
- Utgivningsdatum2009-09-10
- Mått181 x 231 x 43 mm
- Vikt1 280 g
- FormatHäftad
- SpråkEngelska
- SerieAddison-Wesley Professional Computing Series
- Upplaga2
- FörlagPearson Education (US)
- ISBN9780321336330
Tillhör följande kategorier
John K. Ousterhout is a professor of computer science at Stanford University and chairman of Electric Cloud, Inc. Ousterhout created Tcl and is well-known for his work in distributed operating systems, high-performance file systems, and user interfaces. A member of the National Academy of Engineering and recipient of the ACM Software System Award (for Tcl), he has served as professor of computer science at UC Berkeley, distinguished engineer at Sun Microsystems, and CEO of Scriptics, which he founded.Ken Jones, president of Avia Training and Consulting, has spent thousands of hours teaching Tcl to IT professionals. He has more than twenty years of experience training developers through live courses and documentation. As lead instructor at Scriptics, he worked closely with John K. Ousterhout and many other key Tcl developers. Jones coauthored Practical Programming in Tcl and Tk, Fourth Edition (Prentice Hall, 2003).
- Preface xxvPreface to the First Edition xxviiIntroduction xxxiPART I: The Tcl Language 1Chapter 1: An Overview of Tcl and Tk 31.1: Getting Started 31.2: “Hello, World!” with Tk 61.3: Script Files 81.4: Variables and Substitutions 111.5: Control Structures 121.6: On the Tcl Language 141.7: Event Bindings 151.8: Additional Features of Tcl and Tk 19Chapter 2: Tcl Language Syntax 212.1: Scripts, Commands, and Words 212.2: Evaluating a Command 222.3: Variable Substitution 242.4: Command Substitution 262.5: Backslash Substitution 262.6: Quoting with Double Quotes 282.7: Quoting with Braces 292.8: Argument Expansion 302.9: Comments 322.10: Normal and Exceptional Returns 352.11: More on Substitutions 36Chapter 3: Variables 393.1: Commands Presented in This Chapter 393.2: Simple Variables and the set Command 413.3: Tcl’s Internal Storage of Data 413.4: Arrays 423.5: Variable Substitution 433.6: Multidimensional Arrays 453.7: Querying the Elements of an Array 463.8: The incr and append Commands 473.9: Removing Variables: unset and array unset 493.10: Predefined Variables 493.11: Preview of Other Variable Facilities 50Chapter 4: Expressions 534.1: Commands Presented in This Chapter 534.2: Numeric Operands 544.3: Operators and Precedence 554.4: Math Functions 584.5: Substitutions 604.6: String Manipulation 624.7: List Manipulation 634.8: Types and Conversions 634.9: Precision 64Chapter 5: String Manipulation 655.1: Commands Presented in This Chapter 655.2: Extracting Characters: string index and string range 695.3: Length, Case Conversion, Trimming, and Repeating 705.4: Simple Searching 705.5: String Comparisons 715.6: String Replacements 725.7: Determining String Types 735.8: Generating Strings with format 745.9: Parsing Strings with scan 765.10: Glob-Style Pattern Matching 785.11: Pattern Matching with Regular Expressions 795.12: Using Regular Expressions for Substitutions 875.13: Character Set Issues 895.14: Message Catalogs 915.15: Binary Strings 95Chapter 6: Lists 1016.1: Commands Presented in This Chapter 1016.2: Basic List Structure and the lindex and llength Commands 1036.3: Creating Lists: list, concat, and lrepeat 1056.4: Modifying Lists: lrange, linsert, lreplace, lset, and lappend 1066.5: Extracting List Elements: lassign 1096.6: Searching Lists: lsearch 1106.7: Sorting Lists: lsort 1116.8: Converting between Strings and Lists: split and join 1116.9: Creating Commands as Lists 113Chapter 7: Dictionaries 1157.1: Commands Presented in This Chapter 1167.2: Basic Dictionary Structure and the dict get Command 1187.3: Creating and Updating Dictionaries 1207.4: Examining Dictionaries: The size, exists, keys, and for Subcommands 1227.5: Updating Dictionary Values 1237.6: Working with Nested Dictionaries 126Chapter 8: Control Flow 1318.1: Commands Presented in This Chapter 1318.2: The if Command 1328.3: The switch Command 1338.4: Looping Commands: while, for, and foreach 1368.5: Loop Control: break and continue 1388.6: The eval Command 1398.7: Executing from Files: source 140Chapter 9: Procedures 1439.1: Commands Presented in This Chapter 1439.2: Procedure Basics: proc and return 1449.3: Local and Global Variables 1469.4: Defaults and Variable Numbers of Arguments 1469.5: Call by Reference: upvar 1489.6: Creating New Control Structures: uplevel 1509.7: Applying Anonymous Procedures 151Chapter 10: Namespaces 15510.1: Commands Presented in This Chapter 15510.2: Evaluating Tcl Code in a Namespace 15810.3: Manipulating Qualified Names 16110.4: Exporting and Importing Namespace Commands 16210.5: Inspecting Namespaces 16310.6: Working with Ensemble Commands 16410.7: Accessing Variables from Other Namespaces 16910.8: Controlling the Name Resolution Path 170Chapter 11: Accessing Files 17311.1: Commands Presented in This Chapter 17311.2: Manipulating File and Directory Names 17611.3: The Current Working Directory 17911.4: Listing Directory Contents 17911.5: Working with Files on Disk 18111.6: Reading and Writing Files 18511.7: Virtual File Systems 19411.8: Errors in System Calls 196Chapter 12: Processes and Interprocess Communication 19712.1: Commands Presented in This Chapter 19712.2: Terminating the Tcl Process with exit 19912.3: Invoking Subprocesses with exec 19912.4: I/O to and from a Command Pipeline 20312.5: Configuring Channel Options 20412.6: Event-Driven Channel Interaction 20612.7: Process IDs 20912.8: Environment Variables 21012.9: TCP/IP Socket Communication 21012.10: Sending Commands to Tcl Programs 214Chapter 13: Errors and Exceptions 21913.1: Commands Presented in This Chapter 21913.2: What Happens after an Error? 22013.3: Generating Errors from Tcl Scripts 22213.4: Trapping Errors with catch 22213.5: Exceptions in General 22313.6: Background Errors and bgerror 227Chapter 14: Creating and Using Tcl Script Libraries 22914.1: Commands Presented in This Chapter 23014.2: The load Command 23214.3: Using Libraries 23214.4: Autoloading 23314.5: Packages 23414.6: Tcl Modules 23914.7: Packaging Your Scripts as Starkits 242Chapter 15: Managing Tcl Internals 24715.1: Commands Presented in This Chapter 24715.2: Time Delays 25315.3: Time and Date Manipulation 25415.4: Timing Command Execution 25915.5: The info Command 25915.6: Tracing Operations on Simple Variables 26415.7: Tracing Array Variables 26815.8: Renaming and Deleting Commands 26915.9: Tracing Commands 27015.10: Unknown Commands 27215.11: Slave Interpreters 274Chapter 16: History 28316.1: Commands Presented in This Chapter 28316.2: The History List 28416.3: Specifying Events 28516.4: Re-executing Commands from the History List 28516.5: Shortcuts Implemented by unknown 28616.6: Current Event Number: history nextid 287PART II: Writing Scripts for Tk 289Chapter 17: An Introduction to Tk 29117.1: A Brief Introduction to Windowing Systems 29217.2: Widgets 29417.3: Applications, Toplevel Widgets, and Screens 29617.4: Scripts and Events 29717.5: Creating and Destroying Widgets 29717.6: Geometry Managers 29817.7: Widget Commands 29917.8: Commands for Interconnection 300Chapter 18: A Tour of the Tk Widgets 30318.1: Widget Basics 30418.2: Frames 30618.3: Color Options 30718.4: Toplevels 30818.5: Labels 30918.6: Labelframes 31218.7: Buttons 31218.8: Listboxes 31718.9: Scrollbars 31818.10: Scales 32118.11: Entries 32318.12: Menus 32718.13: Panedwindow 33418.14: Standard Dialogs 33718.15: Other Common Options 339Chapter 19: Themed Widgets 34319.1: Comparing Classic and Themed Widgets 34319.2: Combobox 34519.3: Notebook 34619.4: Progressbar 34919.5: Separator 35019.6: Sizegrip 35019.7: Treeview 35019.8: Themed Widget States 35819.9: Themed Widget Styles 36019.10: Other Standard Themed Widget Options 364Chapter 20: Fonts, Bitmaps, and Images 36720.1: Commands Presented in This Chapter 36720.2: The font Command 36920.3: The image Command 375Chapter 21: Geometry Managers 38521.1: Commands Presented in This Chapter 38621.2: An Overview of Geometry Management 38721.3: The Gridder 38921.4: The Packer 39621.5: Padding 40421.6: The Placer 40521.7: Hierarchical Geometry Management 40521.8: Widget Stacking Order 40721.9: Other Geometry Manager Options 40821.10: Other Geometry Managers in Tk 409Chapter 22: Events and Bindings 41322.1: Commands Presented in This Chapter 41322.2: Events 41422.3: An Overview of the bind Command 41622.4: Event Patterns 41722.5: Sequences of Events 41922.6: Substitutions in Scripts 41922.7: Conflict Resolution 42122.8: Event-Binding Hierarchy 42222.9: When Are Events Processed? 42322.10: Named Virtual Events 42522.11: Generating Events 42722.12: Logical Actions 42822.13: Other Uses of Bindings 431Chapter 23: The Canvas Widget 43323.1: Canvas Basics: Items and Types 43323.2: Manipulating Items with Identifiers and Tags 43623.3: Bindings 43923.4: Canvas Scrolling 44423.5: PostScript Generation 445Chapter 24: The Text Widget 44724.1: Text Widget Basics 44724.2: Text Indices and Marks 45024.3: Search and Replace 45124.4: Text Tags 45324.5: Virtual Events 45824.6: Embedded Windows 45924.7: Embedded Images 46024.8: Undo 46224.9: Peer Text Widgets 464Chapter 25: Selection and the Clipboard 46725.1: Commands Presented in This Chapter 46825.2: Selections, Retrievals, and Types 46925.3: Locating and Clearing the Selection 47025.4: Supplying the Selection with Tcl Scripts 47125.5: The clipboard Command 47325.6: Drag and Drop 474Chapter 26: Window Managers 47726.1: Commands Presented in This Chapter 47826.2: Window Sizes 48126.3: Window Positions 48226.4: Gridded Windows 48326.5: Window States 48426.6: Decorations 48526.7: Special Handling: Transients, Groups, and Override-Redirect 48626.8: System-Specific Window Attributes 48726.9: Dockable Windows 48826.10: Window Close 48926.11: Session Management 490Chapter 27: Focus, Modal Interaction, and Custom Dialogs 49127.1: Commands Presented in This Chapter 49127.2: Input Focus 49327.3: Modal Interactions 49527.4: Custom Dialogs 499Chapter 28: More on Configuration Options 50528.1: Commands Presented in This Chapter 50528.2: The Option Database 50628.3: Option Database Entries 50728.4: The RESOURCE_MANAGER Property and .Xdefaults File 50828.5: Priorities in the Option Database 50928.6: The option Command 51028.7: The configure Widget Command 51128.8: The cget Widget Command 512Chapter 29: Odds and Ends 51329.1: Commands Presented in This Chapter 51329.2: Destroying Widgets 51429.3: The update Command 51429.4: Information about Widgets 51629.5: The tk Command 51629.6: Variables Managed by Tk 51729.7: Ringing the Bell 518PART III: Writing Tcl Applications in C 519Chapter 30: Tcl and C Integration Philosophy 52130.1: Tcl versus C: Where to Draw the Line 52330.2: Resource Names–Connecting C Constructs to Tcl 52430.3: “Action-Oriented” versus “Object-Oriented” 52530.4: Representing Information 526Chapter 31: Interpreters 52731.1: Functions Presented in This Chapter 52731.2: Interpreters 52931.3: A Simple Tcl Application 53031.4: Deleting Interpreters 53131.5: Multiple Interpreters 531Chapter 32: Tcl Objects 53332.1: Functions Presented in This Chapter 53432.2: String Objects 53732.3: Numerical Objects 53732.4: Fetching C Values from Objects 53832.5: The Dynamic Nature of a Tcl Object 53932.6: Byte Arrays 54032.7: Composite Objects 54032.8: Reference Counting 54032.9: Shared Objects 54132.10: New Object Types 54232.11: Parsing Strings 54332.12: Memory Allocation 544Chapter 33: Evaluating Tcl Code 54533.1: Functions Presented in This Chapter 54533.2: Evaluating Tcl Code 54633.3: Dynamically Building Scripts 54833.4: Tcl Expressions 549Chapter 34: Accessing Tcl Variables 55134.1: Functions Presented in This Chapter 55134.2: Setting Variable Values 55334.3: Reading Variables 55534.4: Unsetting Variables 55634.5: Linking Tcl and C Variables 55634.6: Setting and Unsetting Variable Traces 55834.7: Trace Callbacks 55934.8: Whole-Array Traces 56134.9: Multiple Traces 56134.10: Unset Callbacks 562Chapter 35: Creating New Tcl Commands 56335.1: Functions Presented in This Chapter 56335.2: Command Functions 56635.3: Registering Commands 56735.4: The Result Protocol 56935.5: Tcl_AppendResult 56935.6: Tcl_SetResult and interp->result 57035.7: clientData and Deletion Callbacks 57235.8: Deleting Commands 57535.9: Fetching and Setting Command Parameters 57635.10: How Tcl Procedures Work 57835.11: Command Traces 579Chapter 36: Extensions 58136.1: Functions Presented in This Chapter 58136.2: The Init Function 58236.3: Packages 58336.4: Namespaces 58436.5: Tcl Stubs 58436.6: The ifconfig Extension 585Chapter 37: Embedding Tcl 59337.1: Functions Presented in This Chapter 59337.2: Adding Tcl to an Application 59437.3: Initialize Tcl 59537.4: Creating New Tcl Shells 596Chapter 38: Exceptions 59938.1: Functions Presented in This Chapter 59938.2: Completion Codes 60038.3: Setting errorCode 60338.4: Managing the Return Options Dictionary 60438.5: Adding to the Stack Trace in errorInfo 60538.6: Tcl_Panic 608Chapter 39: String Utilities 61139.1: Functions Presented in This Chapter 61139.2: Dynamic Strings 61739.3: String Matching 62139.4: Regular Expression Matching 62239.5: Working with Character Encodings 62439.6: Handling Unicode and UTF-8 Strings 62539.7: Command Completeness 627Chapter 40: Hash Tables 62940.1: Functions Presented in This Chapter 63040.2: Keys and Values 63140.3: Creating and Deleting Hash Tables 63240.4: Creating Entries 63340.5: Finding Existing Entries 63540.6: Searching 63640.7: Deleting Entries 63740.8: Statistics 638Chapter 41: List and Dictionary Objects 63941.1: Functions Presented in This Chapter 63941.2: Lists 64241.3: Dictionaries 644Chapter 42: Channels 64942.1: Functions Presented in This Chapter 64942.2: Channel Operations 65642.3: Registering Channels 65842.4: Standard Channels 66042.5: Creating a New Channel Type 661Chapter 43: Handling Events 67143.1: Functions Presented in This Chapter 67143.2: Channel Events 67243.3: Timer Events 67643.4: Idle Callbacks 67743.5: Invoking the Event Dispatcher 678Chapter 44: File System Interaction 68144.1: Tcl File System Functions 68144.2: Virtual File Systems 683Chapter 45: Operating System Utilities 68545.1: Functions Presented in This Chapter 68545.2: Processes 68745.3: Reaping Child Processes 68945.4: Asynchronous Events 69045.5: Signal Names 69345.6: Exiting and Cleanup 69345.7: Miscellaneous 694Chapter 46: Threads 69546.1: Functions Presented in This Chapter 69546.2: Thread Safety 69746.3: Building Threaded Tcl 69746.4: Creating Threads 69746.5: Terminating Threads 69846.6: Mutexes 69846.7: Condition Variables 69946.8: Miscellaneous 701Chapter 47: Building Tcl and Extensions 70347.1: Building Tcl and Tk 70347.2: The Tcl Extension Architecture (TEA) 70747.3: Building Embedded Tcl 714Appendixes 715Appendix A: Installing Tcl and Tk 717A.1: Versions 717A.2: Bundled Tcl Distributions 718A.3: ActiveTcl 718A.4: Tclkits 719A.5: Compiling Tcl/Tk from Source Distributions 719Appendix B: Extensions and Applications 721B.1: Obtaining and Installing Extensions 721B.2: TkCon Extended Console 724B.3: The Standard Tcl Library, Tcllib 725B.4: Additional Image Formats with Img 725B.5: Sound Support with Snack 725B.6: Object-Oriented Tcl 726B.7: Multithreaded Tcl Scripting 727B.8: XML Programming 727B.9: Database Programming 728B.10: Integrating Tcl and Java 728B.11: SWIG 729B.12: Expect 729B.13: Extended Tcl 730Appendix C: Tcl Resources 731C.1: Online Resources 731C.2: Books 732Appendix D: Tcl Source Distribution License 735Index 737