Kwizzz's Scratchpad


This is my preferred way developing applications in Tcl under Windows.

  1. No need to install Tcl (no administrator privileges required)
  2. No need to find out about teacup's folder structure and placement of libraries, finding out which parts of the structure are required (you do not want to copy your complete library, do you?) and copying them to the vfs directory
  3. No need to find out if all required libraries are copied into the vfs folder (had lots of confusion with this because of the application including locally installed libraries instead of those in vfs folder)
  4. Extremely easy to distribute -- no need for my colleagues to install any distribution (did I mention that no admin privileges are required?)


Create a simple Tcl template script file, e.g. application.tcl:

  puts "Hello, world!"

Now create a kit from that file

  $ tclkitsh sdx qwrap application.tcl

This will create a file application.kit. In order to start development, unwrap the kit file into a folder (application.vfs):

  $ tclkitsh sdx unwrap application.kit

The folder will contain a file called main.tcl which will do all the initialization for you and a folder called lib. This folder also contains a subfolder app-application where you will find your good old template script application.tcl and the proper pkgIndex.tcl.

Test it:

  $ tclkitsh application.vfs\main.tcl

You're done! No it's time for adding real code.


Edit your script file application.vfs\lib\app-application\application.tcl and test your application as you like

  $ tclkitsh application.vfs\main.tcl

or if it's a Tk application

  $ tclkit application.vfs\main.tcl

At some time you will need to add libraries. Don't worry, this is really easy! Say you require tdom, you will edit your application.tcl file found in the vfs folder placing

  package require tdom

in it. In order to load the package, download the appropriate zip file from the tdom homepage and unzip it into the lib folder. That's all. Thank's to Tclkit's mechanisms, the unzipped package will be loaded as usual.

The same applies to tcllib: download it and unzip it in the lib folder.

Test your program, add more code, edit, rinse, repeat.

Ain't that easy and convenient?


Once you decide that your program is ready for distribution, pack it into a kit file:

  $ tclkitsh sdx wrap application

This will create a kit file application (note that with current sdx, the .kit extension is missing) and a batch file application.bat.

You might want to rename the kit file to application.kit and distribute tclkit.exe or tclkitsh.exe with it. Or even better:

  $ tclkit sdx wrap application -runtime tclkitsh.exe

for a command line program (you cannot use the same executable for the creation of your application and the -runtime switch) or

  $ tclkitsh sdx wrap application -runtime tclkit.exe

You can also have a copy of tclkitsh.exe at hand, say tclkitsh-copy.exe and type

  $ tclkitsh sdx wrap application -runtime tclkitsh-copy.exe

Above commands will create a file called application, again, with missing extension. Thus, in order to execute it, rename the file:

  $ move application application.exe

Now you are ready to distribute your work :-)

Did I already mention that I love Tclkit and sdx?

Cheatsheet for tdom

TODO: add information on parsing stuff, e.g. parsing nmap's XML structure. This information might go to a separate page anyway.

Controlling Word, Excel, Outlook & Others

TODO: add information gathered along my poor miserable life with MS products