tcl Getting started with tcl

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Remarks

Tcl is a cross platform language with full unicode support.

Flexibility: redefine or enhance existing commands or write new commands.

Event driven programming: Event driven I/O and variable tracing.

Library Interface: It is very easy to integrate existing C libraries into Tcl and provide a Tcl interface to the C library. These interface "stubs" are not tied to any particular version of Tcl and will continue to work even after upgrading Tcl.

Tcl Interface: Tcl provides a complete API so you use the Tcl interpreter from within your C/Python/Ruby/Java/R program.

Versions

VersionNotesRelease Date
8.6.6Current Patch Release.2016-07-27
8.6.52016-02-29
8.6.42015-03-12
8.6.32014-11-12
8.6.22014-08-27
8.6.12013-09-20
8.6.0Current recommended version series for new code. Introduced object system and non-recursive execution engine.2013-09-20
8.5.19Current LTS release2016-02-12
8.5.182015-03-06
8.5.172014-10-25
8.5.162014-08-25
8.5.152013-09-18
8.5.142013-04-03
8.5.132012-11-12
8.5.122012-07-27
8.5.112011-11-04
8.5.102011-06-24
8.5.92010-09-08
8.5.82009-11-16
8.5.72009-04-15
8.5.62008-12-23
8.5.52008-10-15
8.5.42008-08-15
8.5.32008-06-30
8.5.22008-03-28
8.5.12008-02-05
8.5.0Current oldest supported version. Introduced expansion syntax, dictionaries and ensemble commands.2007-12-20
8.4.20Final 8.4 series release. There will be no further releases of 8.4.2013-06-01
8.4.192008-04-18
8.4.182008-02-08
8.4.172008-01-04
8.4.162007-09-21
8.4.152007-05-25
8.4.142006-10-19
8.4.132006-04-19
8.4.122005-12-03
8.4.112005-06-28
8.4.102005-06-04
8.4.92004-12-07
8.4.82004-11-22
8.4.72004-07-25
8.4.62004-03-01
8.4.52003-11-24
8.4.42003-07-22
8.4.32003-05-19
8.4.22003-03-03
8.4.12002-10-22
8.4.0First release by Tcl Core Team. Many performance enhancements. Improved 64-bit support.2002-09-18
8.3.52002-10-18
8.3.42001-10-19
8.3.32001-04-06
8.3.22000-08-09
8.3.12000-04-26
8.3.0Performance improvements.2000-02-10
8.2Stabilisation release1999-08-18
8.1Introduced Unicode support.1999-04-30
8.0Introduced bytecode compilation engine1997-08-16

Features of Tcl

  • Cross Platform Portability
    • Runs on Windows, Mac OS X, Linux, and virtually every variant of unix.
  • Event driven programming
    • Trigger events based on variable read / write / unset.
    • Trigger events when a command is entered or left.
    • Trigger events when a I/O channel (file or network) becomes readable / writable.
    • Create your own events.
    • Trigger a command based on a timer.
  • Object Oriented Programming
    • Mixins.
    • Superclasses and subclasses.
  • Simple Grammar
  • Full unicode support
    • It just works. No special commands are needed to handle unicode strings.
    • Convert to and from different encoding systems with ease.
  • Flexible
    • Create new control structures and commands.
    • Access variables in the calling procedure's context.
    • Execute code in the calling procedure's context.
  • Powerful introspection capabilities.
    • Many Tcl debuggers have been written in Tcl.
  • Library interface
    • Integrate existing C libraries and provide a Tcl interface to the library.
    • Library "stubs" are not tied to any particular version of Tcl and will still work after a Tcl upgrade.
  • Complete API
    • Embed a Tcl interpreter into your favorite language.
    • Python, Ruby, R, Java and others include a Tcl API.
  • Embedded bigint library.
    • No special actions are needed to handle very large numerics.
  • Safe interpreters
    • Create sandboxes in which user code can be run.
    • Enable and disable specific commands for the interpreter.
  • Regular Expressions
    • A powerful and fast regular expression engine written by Henry Spencer (creator of regex).

Installation

Installing Tcl 8.6.4 on Windows :

  1. The easiest way to get Tcl on a windows machine is to install the ActiveTcl distribution from ActiveState.

  2. Navigate to www.activestate.com and follow the links to download the Free Community Edition of ActiveTcl for Windows (choose 32/64 bit version appropriately).

  3. Run the installer which will result in a fresh install of ActiveTcl usually in the C:\Tcl directory.

  4. Open a command prompt to test the install, type in "tclsh" which should open an interactive tcl console. Enter "info patchlevel" to check the version of tcl that was installed and it should display an output of the form "8.6.x" depending on the edition of ActiveTcl that has been downloaded.

  • You may also want to add "C:\Tcl\bin" or its equivalent to your environment PATH variable.
C:\>tclsh
% info patchlevel
8.6.4
 

Installing packages through teacup

Now days many languages are supporting archive server to install their packages into your local machine. TCL also having same archive server we called it as Teacup

teacup version
teacup search <packageName>

Example

teacup install Expect

The Hello, world program in Tcl (and Tk)

The following code can be entered in a Tcl shell (tclsh ), or into a script file and run through a Tcl shell:

puts "Hello, world!"
 

It gives the string argument Hello, world! to the command puts . The puts command writes its argument to standard out (your terminal in interactive mode) and adds a newline afterwards.


In a Tk-enabled shell, this variation can be used:

pack [button .b -text "Hello, world!" -command exit]
 

It creates a graphic button with the text Hello, world! and adds it to the application window. When pressed, the application exits.

A Tk-enabled shell is started as: wish Or using tclsh along with the following statement:

package require Tk 
 


Got any tcl Question?