How to debug a TCL script using eclipse

Eclipse is consider as good IDE for development as well as debugging . In last article we have seen how to configure eclipse to run TCL script here is the link . If you didn’t configure eclipse for TCL then first do that because it is mandatory to configure eclipse for TCL debugging.

In this article we will see how to configure eclipse to debug TCL script . For this we would need to download Activestate’s remote debugger from this link http://code.activestate.com/komodo/remotedebugging/ .
On this link you will see debugger for Pearl, PHP, Paython, Ruby and TCL. We would choose TCL remote debugger for Windows. Check Screenshot below :
download TCL debugger

After downloading extract the zip package, and paste the package somewhere . Now open eclipse go to menu -> Windows -> Preferences . In preferences expand TCL->Debug -> Engines -> Active State . Go to Paths Tab -> External Debugging Engine Section . Browse to path of dbgp_tcldebug.exe which is located in package we just pasted . Check Screen below:

configure debugger with eclipseWe have successfully configured debugger . Its time to debug the TCL script. Take sample script or you can take this simple script which checks whether number is even or odd .

puts "Program to find even odd numbers"

set num 8

if { $num % 2 == 0 } {
 
 puts "number is even" 
 
} else {
 
 puts "number is odd " 

}

 

Save the script with some name and add breakpoint to script. Now go to Run and click on debug to start debugging. You can use different commands like Step Into , Step Over , Step Return , Resume , Terminate.

eclipse debug menuYou can use Step into to go inside in procedure and Step Over is used if you don’t want to debug the Procedure code. Resume and Terminate are used to resume program flow and Terminate current execution respectively.

For more details you can check our video tutorial on youtube.com

Try to configure eclipse for debugging. You can add your comments !

How to configure Eclipse as TCL IDE

Eclipse is best IDE for development. We can use same Eclipse for development of TCL, but we will need to configure it . Dynamic Languages Toolkit (DLTK) http://www.eclipse.org/dltk/ is set of frameworks which provides Tcl, Ruby, Javascript and Python development environments.

So to configure eclipse for TCL we need to download Dynamic Languages Toolkit. In this Toolkit we have other libraries too, but we will download only for TCL. After configuration we can run program directly from Eclipse .If you want to debug TCL Program we would need to configure debugger separately .

Let’s start with configuration of Eclipse for TCL development .

1. Downlaod TCL SDK and install . If you don’t know how to install TCL on windows you can refer our last post: How to install and run TCL on this link http://fervort.com/blog/2015/12/how-to-install-and-run-tcl/

2. Download and Install Eclipse IDE for Java/JavaEE Developer . You can download from here https://eclipse.org/downloads/

3. Start Eclipse and go to menu Help -> Install New Software . In Install window click on Add… button to add Repository details. You can give any name in Name field and add location link as http://download.eclipse.org/technology/dltk/updates-dev/1.0/  . See Screenshot for details.

install dltk
After clicking on Okay, It will show you all available packages. But for TCL we will select Dynamic Language Toolkit – TCL Developments Tools . See Screenshot for details.

Eclipse TCL Development Tools4. Click on Install and Accept License Agreement. Click on Finish and wait till Eclipse install all the required packages. After successful installation eclipse will ask to restart. Just restart the Eclipse.

5. Next step is to setup TCL interpreter with Eclipse. For this go to Menu Windows -> Preferences . On left side select TCL tab. Expand it and select Interpreter. Click on add and browse to tclsh.exe located in bin directory of installation. See screenshot.

tcl interpreter eclipse

Till now we have configured eclipse for TCL. In next step we will create TCL project.

6. To create project go to Menu File->Project-> TCL Project. (See screenshot). Give name to project and click on finish.

New Eclipse TCL Project7. To add new TCL file right click on newly created project New -> TCL File. Give name to TCL file with extension .tcl and click on finish.

8. Add some TCl lines and right click on file -> Run As -> TCL Script .

Run as TCL Script

You can see output in console window. See screenshot .

eclipse-tcl-outputYou can check our Video tutorial for installation and configuration of Eclipse for TCL on YouTube here https://www.youtube.com/watch?v=ThL7qZN2msY

Try to configure Eclipse . Feel free to comment 🙂

How to install and Run TCL

In this article, we will see how to install TCL on windows and run it. First we will download TCL from this link http://www.activestate.com/activetcl/downloads  .

Choose the binaries depend on your System types either 64 bit or 32 bit. Double click on downloaded setup to start installing TCL.

installing-tcl

Accept license agreement.

TCL license agreementChoose path. I am installing on C:\Tcl default path

installing tcl path

So TCL is installed on your windows.  Now we will set path of C:\Tcl\bin\ directory so, we can run it from any location.

To set path just copy the path up to bin directory ( In my case it is C:Tcl\bin\ ) and fire command like this

set tcl path windows

Path is set so we can run TCL from any location. Lets try to run it from D drive. First create one small TCL and save it on D drive with name Hello.tcl . So the path is D:\Hello.tcl

tcl in notepad

To run this file open command prompt and go to path D: and execute command tclsh Hello.tcl like this .
running tcl
It will print output Hello World !

Introduction to TCL

TCL (Tool Command Language) programming language was created by John Ousterhout in 1988 at the University of California, Berkeley. It is scripting language and commonly used for rapid prototyping, scripted applications and testing.

In 1994 John Ousterhout joined Sun Microsystems and with help of Tcl team he has added lot of new feature in TCL and TK.

These are some Important events : 

  • First talk on TCL by John Ousterhout in 1989 at Berkeley Industrial Liaison Conference.
  • First paper presented in 1990 at USENIX Conference by John Ousterhout.
  • In 1990 first TCL community was formed.
  • In 1993 Larry Rowe organized the first Tcl Workshop at Berkeley.
  • John Ousterhout joined Sun Microsystems and start building a team of Tcl developers.
  • TCL and Tk was ported to Windows and Macintosh by Scott Stanton and Ray Johnson.
  • In January 1998 John Ousterhout founded Scriptics with Sarah Daniels to focus on TCL.

Let us see first program in TCL .

puts “Hello World!”

Save this program as Hello.tcl and you can run it using command :

tclsh Hello.tcl

You can install TCL on your machine or you can also execute TCL online  . Check our next post How to install and Run TCL .