Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Tcl/Tk 8.5 Programming Cookbook
Tcl/Tk 8.5 Programming Cookbook

Tcl/Tk 8.5 Programming Cookbook: With over 100 recipes, this Cookbook is ideal for both beginners and advanced Tcl/Tk programmers. From the basics to creating applications, it’s full of indispensable tips and tricks to make the most of the language.

eBook
€22.99 €25.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Tcl/Tk 8.5 Programming Cookbook

Chapter 1. The Tcl Shell

In this chapter, we will cover the following topics:

  • The Tcl shell

  • Writing to the Tcl console

  • Mathematical expressions

  • Tcl expr operands

  • Tcl expr operators

  • Mathematical functions

  • Computing mathematical expressions

  • Referencing files in Tcl

  • Variables

  • Launching a Tcl script

Introduction

So, you've installed Tcl, written some scripts, and now you're ready to get a deeper understanding of Tcl and all that it has to offer. So, why are we starting with the shell when it is the most basic tool in the Tcl toolbox?

When I started using Tcl I needed to rapidly deliver a Graphical User Interface (GUI) to display a video from the IP-based network cameras. The solution had to run on Windows and Linux and it could not be browser-based due to the end user's security concerns. The client needed it quickly and our sales team had, as usual, committed to a delivery date without speaking to the developer in advance. So, with the requirement document in hand, I researched the open source tools available at the time and Tcl/Tk was the only language that met the challenge.

The original solution quickly evolved into a full-featured IP Video Security system with the ability to record and display historic video as well as providing the ability to attach to live video feeds from the cameras. Next search capabilities were added to review the stored video and a method to navigate to specific dates and times. The final version included configuring advanced recording settings such as resolution, color levels, frame rate, and variable speed playback. All was accomplished with Tcl.

Due to the time constraints, I was not able get a full appreciation of the capabilities of the shell. I saw it as a basic tool to interact with the interpreter to run commands and access the file system. When I had the time, I returned to the shell and realized just how valuable a tool it is and the many capabilities I had failed to make use of.

When used to its fullest, the shell provides much more that an interface to the Tcl interpreter, especially in the early stages of the development process. Need to isolate and test a procedure in a program? Need a quick debugging tool? Need real-time notification of the values stored in a variable? The Tcl shell is the place to go.

Since then, I have learned countless uses for the shell that would not only have sped up the development process, but also saved me several headaches in debugging the GUI and video collection. I relied on numerous dialog boxes to pop up values or turned to writing debugging information to error logs. While this was an excellent way to get what I needed, I could have minimized the overhead in terms of coding by simply relying on the shell to display the desired information in the early stages.

While dialog windows and error logs are irreplaceable, I now add in quick debugging by using the commands the shell has to offer. If something isn't proceeding as expected, I drop in a command to write to standard out and voila! I have my answer. The shell continues to provide me with a reliable method to isolate issues with a minimum investment of time.

Introduction


So, you've installed Tcl, written some scripts, and now you're ready to get a deeper understanding of Tcl and all that it has to offer. So, why are we starting with the shell when it is the most basic tool in the Tcl toolbox?

When I started using Tcl I needed to rapidly deliver a Graphical User Interface (GUI) to display a video from the IP-based network cameras. The solution had to run on Windows and Linux and it could not be browser-based due to the end user's security concerns. The client needed it quickly and our sales team had, as usual, committed to a delivery date without speaking to the developer in advance. So, with the requirement document in hand, I researched the open source tools available at the time and Tcl/Tk was the only language that met the challenge.

The original solution quickly evolved into a full-featured IP Video Security system with the ability to record and display historic video as well as providing the ability to attach to live video feeds from the cameras. Next search capabilities were added to review the stored video and a method to navigate to specific dates and times. The final version included configuring advanced recording settings such as resolution, color levels, frame rate, and variable speed playback. All was accomplished with Tcl.

Due to the time constraints, I was not able get a full appreciation of the capabilities of the shell. I saw it as a basic tool to interact with the interpreter to run commands and access the file system. When I had the time, I returned to the shell and realized just how valuable a tool it is and the many capabilities I had failed to make use of.

When used to its fullest, the shell provides much more that an interface to the Tcl interpreter, especially in the early stages of the development process. Need to isolate and test a procedure in a program? Need a quick debugging tool? Need real-time notification of the values stored in a variable? The Tcl shell is the place to go.

Since then, I have learned countless uses for the shell that would not only have sped up the development process, but also saved me several headaches in debugging the GUI and video collection. I relied on numerous dialog boxes to pop up values or turned to writing debugging information to error logs. While this was an excellent way to get what I needed, I could have minimized the overhead in terms of coding by simply relying on the shell to display the desired information in the early stages.

While dialog windows and error logs are irreplaceable, I now add in quick debugging by using the commands the shell has to offer. If something isn't proceeding as expected, I drop in a command to write to standard out and voila! I have my answer. The shell continues to provide me with a reliable method to isolate issues with a minimum investment of time.

The Tcl shell


The Tcl Shell (Tclsh) provides an interface to the Tcl interpreter that accepts commands from both standard input and text files. Much like the Windows Command Line or Linux Terminal, the Tcl shell allows a developer to rapidly invoke a command and observe the return value or error messages in standard output. The shell differs based on the Operating System in use. For the Unix/Linux systems, this is the standard terminal console; while on a Windows system, the shell is launched separately via an executable.

If invoked with no arguments, the shell interface runs interactively, accepting commands from the native command line. The input line is demarked with a percent sign (%) with the prompt located at the start position. If the shell is invoked from the command line (Windows DOS or Unix/Linux terminal) and arguments are passed, the interpreter will accept the first as the filename to be read. Any additional arguments are processed as variables. The shell will run until the exit command is invoked or until it has reached the end of the text file.

When invoked with arguments, the shell sets several Tcl variables that may be accessed within your program, much like the C family of languages. These variables are:

Variable

Explanation

argc

This variable contains the number of arguments passed in with the exception of the script file name.

A value of 0 is returned if no arguments were passed in.

argv

This variable contains a Tcl List with elements detailing the arguments passed in.

An empty string is returned if no arguments were provided.

argv0

This variable contains the filename (if specified) or the name used to invoke the Tcl shell.

TCL_interactive

This variable contains a '1' if Tclsh is running in interactive mode, otherwise a '0' is contained.

env

The env variable is maintained automatically, as an array in Tcl and is created at startup to hold the environment variables on your system.

Writing to the Tcl console


The following recipe illustrates a basic command invocation. In this example, we will use the puts command to output a "Hello World" message to the console.

Getting ready

To complete the following example, launch your Tcl Shell as appropriate, based on your operating platform. For example, on Windows, you would launch the executable contained in the Tcl installation location within the bin directory, while on a Unix/Linux installation, you would enter TCLsh at the command line, provided this is the executable name for your particular system. To check the name, locate the executable in the bin directory of your installation.

How to do it…

Enter the following command:

% puts "Hello World"
Hello World

How it works…

As you can see, the puts command writes what it was passed as an argument to standard out. Although this is a basic "Hello World" recipe, you can easily see how this 'simple' command can be used for rapid tracking of the location within a procedure, where a problem may have arisen. Add in variable values and some error handling and you can rapidly isolate issues and correct them without the additional efforts of creating a Dialog Window or writing to an error log.

Mathematical expressions


The expr command is used to evaluate mathematical expressions. This command can address everything from simple addition and subtraction to advanced computations, such as sine and cosine. This eliminates the need to make system calls to perform advanced mathematical functions. The expr command evaluates the input and arguments, and returns an integer or floating-point value.

A Tcl expression consists of a combination of operators, operands, and parenthetical containers (parenthesis, braces, or brackets). There are no strict typing requirements, so any white space is stripped by the command automatically. Tcl supports non-numeric and string comparisons as well as Tcl-specific operators.

Tcl expr operands


Tcl operands are treated as integers, where feasible. They may be specified as decimal, binary (first two characters must be 0b), hexadecimal (first two characters must be 0x), or octal (first two characters must be 0o). Care should be taken when passing integers with a leading 0, for example 08, as the interpreter would evaluate 08 as an illegal octal value. If no integer formats are included, the command will evaluate the operand as a floating-point numeric value. For scientific notations, the character e (or E) is inserted as appropriate. If no numeric interpretation is feasible, the value will be evaluated as a string. In this case, the value must be enclosed within double quotes or braces. Please note that not all operands are accepted by all operators. To avoid inadvertent variable substitution, it is always best to enclose the operands within braces. For example, take a look at the following:

  • expr 1+1*3 will return a value of 4.

  • expr (1+1)*3 will return a value of 6.

Operands may be presented in any of the following:

Operand

Explanation

Numeric

Integer and floating-point values may be passed directly to the command.

Boolean

All standard Boolean values (true, false, yes, no, 0, or 1) are supported.

Tcl variable

All referenced variables (in Tcl, a variable is referenced using the $ notation, for example, myVariable is a named variable, whereas $myVariable is the referenced variable).

Strings

(in double quotes)

Strings contained within double quotes may be passed with no need to include backslash, variable, or command substitution, as these are handled automatically (see the chapter on String Expressions and Handling for clarification on these terms and their usage).

Strings

(in braces)

Strings contained within braces will be used with no substitution.

Tcl commands

Tcl commands must be enclosed within square braces.

The command will be executed and the mathematical function is performed on the return value.

Named functions

Functions, such as sine, cosine, and so on.

Tcl supports a subset of the C programming language math operators and treats them in the same manner and precedence. If a named function (such as sine) is encountered, expr automatically makes a call to the mathfunc namespace to minimize the syntax required to obtain the value.

Tcl expr operators may be specified as noted in the following table, in the descending order of precedence:

Operator

Explanation

- + ~ !

Unary minus, unary plus, bitwise NOT and logical NOT.

Cannot be applied to string operands.

Bit-wise NOT may be applied to only integers.

**

Exponentiation

Numeric operands only.

*/ %

Multiply, divide, and remainder.

Numeric operands only.

+ -

Add and subtract.

Numeric operands only.

<< >>

Left shift and right shift.

Integer operands only.

A right shift always propagates the sign bit.

< > <= >=

Boolean Less, Boolean Greater, Boolean Less Than or Equal To, Boolean Greater Than or Equal To (A value of 1 is returned if the condition is true, otherwise a 0 is returned).

If utilized for strings, string comparison will be applied.

== !=

Boolean Equal and Boolean Not Equal (A value of 1 is returned if the condition is true, otherwise a 0 is returned).

eq ne

Boolean String Equal and Boolean String Not Equal (A value of 1 is returned if the condition is true, otherwise a 0 is returned).

Any operand provided will be interpreted as a string.

in ni

List Containment and Negated List Containment (A value of 1 is returned if the condition is true, otherwise a 0 is returned).

The first operand is treated as a string value, the second as a list.

&

Bitwise AND

Integers only.

^

Bitwise Exclusive OR

Integers only.

|

Bitwise OR

Integers only.

&&

Logical AND (a value of 1 is returned if both operands are 0, otherwise a 1 is returned).

Boolean and numeric (integer and floating-point) operands only.

x?y:z

If-then-else (if x evaluates to non-zero, then the return is the value of y, otherwise the value of z is returned).

The x operand must have a Boolean or a numeric value.

Mathematical functions


Mathematical functions (such as sine and cosine) are replaced with a call to the Tcl mathfunc namespace. This does not require any additional syntax to access the namespace as it is called automatically. These are invoked by passing the Function followed by the value or values to evaluate to the expr command. Those functions that accept multiple arguments require that the arguments be comma delimited. The default Mathematical functions are listed below in alphabetical order. These functions require a specific syntax (for example expr {function(value,value)}) to be accessed, as described in the Computing mathematical expressions section that follows:

Function

Result

abs arg

Returns the absolute value of arg.

Numeric operators may be integer or floating-point. Value is returned in the same format.

acos arg

Returns the arc cosine of arg.

asin arg

Returns the arc sine of arg.

atan arg

Returns the Arc Tangent of x/y.

bool arg

Returns the Boolean value of arg where non-numeric values are true, otherwise the value is false.

ceil arg

Returns the smallest floating-point integer value not less than arg.

Any numeric value is acceptable.

cos arg

Returns the cosine of arg, measured in radians.

If the result produces an over-flow, an error is returned.

double arg

Converts arg to its floating-point value.

May return INF or INF when the numeric value is such that it exceeds the floating-point value.

entier arg

Converts arg to its integer value.

exp arg

Returns the exponential of arg.

If the result produces an over-flow, an error is returned.

floor arg

Returns the largest floating-point integer not greater than arg.

The argument may be any numeric value.

fmod x y

Returns the remainder of x/y as a floating-point integer.

If y is a zero (0), then an error is returned.

hypot x y

Returns the length of the hypotenuse of a right angled triangle.

int arg

Returns the low order bits of arg up to the machine word size.

isqrt arg

Returns the integer portion of the square root of arg.

Arg must be a positive value (integer or floating-point).

log arg

Returns the natural logarithm of arg.

arg must be a positive value.

log10 arg

Returns the base 10 logarithm of arg.

arg must be a positive value.

max arg

This function accepts one or more numeric values and returns the greatest.

min arg

This function accepts one or more numeric and returns the least one.

pow x y

Returns the value of x raised to the power y.

If x is zero (0), y must be an integer value.

rand

Returns a pseudo-random floating-point integer in the range of 0, 1.

round arg

Returns the rounded value of arg if arg is an integer value.

If arg is not an integer, it is converted to an integer by rounding and the converted value is returned.

sin arg

Returns the sine of arg as radians.

sinh arg

Returns the hyperbolic sin of arg.

If the result produces an over-flow, an error is returned.

sqrt arg

Returns the square root of arg.

Accepts any non-negative numeric value.

May return INF when the value is a numeric value that exceeds the square of the maximum value for the floating-point range.

srand arg

Resets the seed for the random number generator and returns a random number as described in rand.

tan arg

Returns the tangent of arg as radians.

tanh arg

Returns the hyperbolic tangent of arg.

wide arg

Returns the low order 64 bits of arg.

Accepts any numeric value.

Left arrow icon Right arrow icon

Key benefits

  • The quickest way to solve your problems with Tcl/Tk 8.5
  • Understand the basics and fundamentals of the Tcl/Tk 8.5 programming language
  • Learn graphical User Interface development with the Tcl/Tk 8.5 Widget set
  • Get a thorough and detailed understanding of the concepts with a real-world address book application
  • Each recipe is a carefully organized sequence of instructions to efficiently learn the features and capabilities of the Tcl/Tk 8.5 language

Description

With Tcl/Tk, you can create full-featured cross-platform applications in a simple and easy-to-understand way without any expensive development package; the only tools required are a simple text editor and your imagination. This practical cookbook will help you to efficiently interact with editors, debuggers, and shell type interactive programs using Tcl/Tk 8. This cookbook will comprehensively guide you through practical implementation of Tcl/Tk 8.5 commands and tools. This book will take you through all the steps needed to become a productive programmer in Tcl/Tk 8. Right from guiding you through the basics to creating a stand-alone application, it provides complete explanation of all the steps along with handy tips and tricks. The book begins with an introduction to the Tcl shell, syntax, variables, and programming best practices in the language. It then explores procedures and the flow of events with control constructs followed by advanced error trapping and recovery. From Chapter 4, a detailed study of string expressions and handling enables you to handle various string functions and use lists to expand the string functionality. The book then discusses in-depth the Tcl Dictionary and how to utilize it to store and retrieve data. File operations and Tk GUI handling are covered extensively along with a developing a real-world address book application to practice the concepts learned.

Who is this book for?

If you are a beginner interested in adding Tcl/Tk 8.5 to your list of languages, or an experienced Tcl/Tk programmer looking to sharpen your knowledge, be assured, you will find your prefect guide in this book. Whether you are developing for your personal use or commercial applications, this book will provide you with a ready reference to the building blocks of Tcl/Tk 8.5

What you will learn

  • Expand your Tcl/Tk abilities by gaining in-depth knowledge of the core commands
  • Learn efficient programming by using control constructs in your program
  • Handle numerous types of string expressions by performing formatting, searches, and advanced manipulations on them
  • Gain expertise in using lists with examples teaching you the various available operations
  • Demystify the Tcl Dictionary and learn how it can be a viable substitute for a third-party database
  • Perform various operations on the dictionary elements in both single and multiple layer dictionaries
  • Create, manage, and empower your Graphical User Interface with Tk window management, to develop attractive applications
  • Ease your file system access with an in-depth study of File operations
  • Perform advanced error trapping and recovery with error handling commands in Tcl

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Feb 11, 2011
Length: 236 pages
Edition : 1st
Language : English
ISBN-13 : 9781849512985
Category :
Languages :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Feb 11, 2011
Length: 236 pages
Edition : 1st
Language : English
ISBN-13 : 9781849512985
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 116.97
Network Analysis using Wireshark Cookbook
€41.99
Tcl 8.5 Network Programming
€41.99
Tcl/Tk 8.5 Programming Cookbook
€32.99
Total 116.97 Stars icon

Table of Contents

13 Chapters
The Tcl Shell Chevron down icon Chevron up icon
Using the Building Blocks Control Constructs Chevron down icon Chevron up icon
Error Handling Chevron down icon Chevron up icon
Handling String Expressions Chevron down icon Chevron up icon
Expanding String Functionality Using Lists Chevron down icon Chevron up icon
The Tcl Dictionary Chevron down icon Chevron up icon
File Operations Chevron down icon Chevron up icon
Tk GUI Programming with Tcl/Tk Chevron down icon Chevron up icon
Configuring and Controlling Tk Widgets Chevron down icon Chevron up icon
Geometry Management Chevron down icon Chevron up icon
Using Tcl Built-in Dialog Windows Chevron down icon Chevron up icon
Creating and Managing Menus Chevron down icon Chevron up icon
Creating the Address Book Application Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
(7 Ratings)
5 star 14.3%
4 star 28.6%
3 star 14.3%
2 star 28.6%
1 star 14.3%
Filter icon Filter
Top Reviews

Filter reviews by




Amazon Customer Apr 10, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
good
Amazon Verified review Amazon
Ned Mar 28, 2011
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
(I received a review copy of this book)This book should be very helpful for beginners interested in what Tcl/Tk has to offer, or those who have to maintain "that Tcl app" at work.The table of contents provides a topical list of tasks, and each section can stand on its own - allowing the reader to immediately write code and see results.This couples well with Tcl's orientation towards rapid prototyping, and should provide the taste beginners need to desire more Tcl/Tk.
Amazon Verified review Amazon
WJG Mar 16, 2011
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
When I received my review copy of the Tcl/Tk 8.5 Programming Cookbook I was half expecting a rewrite of the manual -lists of features and functionality with little indication of how and when to use specific resources. I was wrong. Let me explain. A cookbook is something to turn to when you've run out of ideas or perhaps are looking to find some new way of tackling an old problem. Alternatively, cookbooks are for beginners and novices, those people who need to know how do something effectively and quickly. In this area the `Cookbook' score points in every chapter.Turn to any page in the text and you will find a clear, structure on how to use Tcl/Tk to resolve particular issues. There is a task statement, such as 'Creating a List' in which a particular requirement is identified followed by a 'How to Do It' code snippet and a 'Why it Works' explanation. For someone new to Tcl programming this is an excellent approach.Overall, the `Cookbook' is organised over thirteen chapters which cover all the key areas any novice Tcler needs to know. The flow of the book first introduces the reader to the key aspects of Tcl: the shell, program control, error handling, string manipulation, lists, dictionaries (particularly useful) and file operations. Following this it deals with the creation and configuration of GUIs using the Tk widget set and the use of in-built dialogs and the creation of menus. Finally, the issues and decisions surrounding the completion of a first Tcl/Tk project are examined in the form of an address book application.ConclusionThe Tcl/Tk 8.5 Programming CookBook is exactly what it set out to be - a practical tutorial text. It doesn't cover the advanced features of Tcl/Tk but this is intentional. Would I recommend this book to a Tcl/Tk newbie? Yes.
Amazon Verified review Amazon
Highlander Aug 28, 2013
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
Diese Buch ist wirklich nur für absolute Anfänger. Ein Kochbuch für 100 Lösungen ist es aber aus meiner Sicht nicht. Schritt für Schritt wird in die Kommandos eingeführt, allerdings ohne jeden Tiefgang. Ohne dem zusätzlichen Studium der Manpages innerhalb von Tcl kommt man nicht aus. Die Einführung endet dann in einer rudimentären Adressbuch Applikation. Sehr enttäuschen ist, dass der Buchtitel auf Tcl/Tk 8.5 eingeht, aber alle Kommandos bereits ab der alten wish 4.0 funktionieren. Nirgendwo ein Hinweis auf die Spezialitäten der Version 8.5.Der Schwerpunkt liegt in der GUI Programmierung. Leider fehlen die Definitionen für Schriften und Betriebssystemspezifische Designtemplates die gerade mit der Version 8 überarbeitet wurden. 20 Seiten mehr und das ganze wäre erklärt gewesen. Eine weitere Stärke von Tcl war von je her die Port Kommunikation, die ähnlich einem Dateizugriff funktioniert. Auch hier kein Wort vom Autor. Ein einfaches Bespiel zum Zugriff auf eine MySQL Datenbank wäre gerade für eine Adressbuchanwendung toll gewesen. Auch hier nichts.Der Einband weckt mehr Erwartungen, doch es ist eine einfache Einführung in die Syntax von Tcl/Tk. Deshalb noch 3 Sterne.
Amazon Verified review Amazon
Roalt May 12, 2011
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
I was a bit suprised when a representative of Packt asked me to reviewa new Tcl/Tk book: A new Tcl/Tk book? A book about a language thatgets much less attention nowadays than Ruby, Clojure, Python, C#, andeven Java? Yes, it's really true.There are quite some books on Tcl/Tk, albeit that most are alreadyaging. One of the well-known books is Practical Programming withTcl/Tk by Brent Welch that's now in it's 4th edition. So it'squite obvious that any other book shall compete with this book on theshelf about Tcl/Tk programming.But even with all those new languages, Tcl/Tk doesn't really get thecredit it deserves: It's not a web-oriented language (initial attempts torun Tcl/Tk in the browser failed to catch much popularity). But it'sstill strong as scripting language and as language to make userinterfaces, without having to learn a new framework or a newprogramming language. In that sense, Tcl/Tk is an Agile language thatyou can pick up and extend your knowledge as you go.The book is, as the name suggests, written in the Cookbook-style: Easyto distinguish topics with examples and simple answers. I like thestyle as it's both useful as tutorial book, to read from front to end,as for reference book where you can skip to the topic or issue and read it.The books starts with the Tcl shell syntax, then it describes thestandard control structures, error handling, and then continues to thevarious variable types of the language, such as strings, lists anddictionaries. After discussing the core Tcl features, the books moveson to the Tk-part of Tcl/Tk, the user interface. The differentstandard components are discussed, at the end of the book an exampleis given of an address book application.Although the book, in essence, can be a good addition to what'savailable, when I first browsed through it, I got a bit of saddenedfeeling: There were some typos and errors (e.g. TCL_interactiveinstead of tcl_interactive), and more important: the code indentationis broken throughout the whole book: I know you can have differentopinions on this subject, but I cannot believe the author applies itas it is done in the book. I sincerely hope these layout problems andsome errata's will trigger a second edition release.There are also some other issues that I noticed related to the order:For instance, first regular expressions are discussed. A view pageslater, the simple string search is discussed. If you're reading thebook as tutorial, you might this order a bit unnatural. I also miss adiscussion of the namespace functionality in Tcl/Tk: if you want towrite larger applications, it prevents serious scaling problems andthe use of global variables.The Tk-part of the book is not complete, some important (advanced)techniques are missing. For instance, to control the input of a entrywidget, or handle the scrollbar with the -xscrollcommand and-yscrollcommand (the scrollbar isn't even mentioned). In that sense,if you do not consider it an advanced Tcl/Tk book, it's allright, butyou might miss out these important topics otherwise. The address book application is a section of the book I find a bitmisplaced: it looks like it's just a listing of a (long) application,that is described afterwards. Although I like long examplesdiscussing more complex issues with the language or see the topicscombined in one example, I doubt this example will be encouragingenough for the reader. A reference to where the source code can befound would be more than sufficient, and it would leave room todiscuss the important decisions made in this application.Concluding, I must say that for an entry-level Tcl/Tk book it's a goodand easy accessible book. But if you intend to get a fullunderstanding of the language, you will require at least oneadditional book (or read a lot of internet or manual pages). And someissues, especially the indentation, must be taken care of in a reprintbefore I can give a positive recommendation.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.