Tom Poindexter's Tcl Page

Tool Command Language (Tcl)

Tcl-Wear!

Tcl Wear Not just great software, but things you can wear! According to the Completely Generic Tcl/Tk Game Show at the 1998 Tcl Conference, the fourth most popular reason to attend Tcl Conferences is to collect tee shirts and other fun stuff. See what Tcl'ers are wearing by visiting A Tcl-Wear Chronology.

Tcl is the creation of Dr. John K. Ousterhout. Tcl was designed as an embeddable command language, but is strong enough to stand as a general programming language. Tcl is often associated with its primary extension Tk, which provides an elegantly simple interface for X Window System programming.

One of Tcl's design features is that it is easily extended. I've written two Tcl extensions for two popular relational database systems, Sybase and Oracle. My extensions are named Sybtcl and Oratcl respectively.

Other Tcl software distributions I've published are TclRobots, a Tcl programming game, Tcl-my-fancy, a Tcl extension configuration utility, and MSTCL7.3, a port of Tcl/Tk to MS-DOS. Mpexpr, a multiple precision math package, and Fcgi.tcl, an interface to the FastCGI protocol.

There's serveral Web pages on Tcl, including ones at the Tcl Consortium, SCO and Scriptics. A very nice Tcl index of sources, code, extensions, FAQs, etc. is Procplace, which holds the historical Tcl Internet archives. All of my software listed here can be found at ftp://ftp.procplace.com/pub/tcl , or follow the http links listed below.

I have authored two chapters on Sybtcl and Oratcl for Tcl/Tk Tools. My chapters provide detail on Sybtcl and Oratcl programming, plus coverage of Wisqlite and Wosql.


Sybtcl

Sybtcl is a Tcl extension that adds an interface to the Sybase relational database system. Sybtcl creates several new commands in Tcl to connect to a Sybase server, send SQL statements, fetch return rows, read and write image columns to files, and query return column names, types, and lengths. In addition to fetching result rows, output variables and return values from stored procedures can be accessed. Full access to Sybase server return codes and error message are also available.

You can read more about Sybtcl in Tcl/Tk Tools.

Here is a small sample of Sybtcl code that connects to a Sybase server, sends an SQL query, then prints the results:


set hand [sybconnect "mysybid" "mysybpasswd"]
sybuse $hand pubs2
sybsql $hand "select au_lname, au_fname from authors order by au_lname"
sybnext $hand {
  puts [format "%s, %s" @1 @2]
}
sybclose $hand

Together with Tk, Sybtcl can be a rapid development tool for building X Window based Sybase applications.

The Sybtcl distribution includes Wisqlite, an X Window based SQL processor. A sample screen shot is here (15k).

One of the first Sybtcl programmers, De Clarke, has extended Wisqlite into a very extensive tool, called UCO/Wisql. De has also done work with Sybtcl and interfacing with WWW to serve campus phone numbers via a web page, and another application to browse star catalogs. Check out De's Sybtcl-to-WWW demo page and home page.

The current beta version is 3.0b3 released April, 1999, and can be found at ftp://ftp.procplace.com/pub/tcl/sorted/databases/Sybtcl-3.0b3/3.0b3/sybtcl-3.0b3.tar.gz Sybtcl-3.0b3 supports Tcl 8.0 and higher.

The current stable version is 2.5 released January, 1998, and can be found at ftp://ftp.procplace.com/pub/tcl/sorted/databases/sybtcl-2.5/sybtcl-2.5.tar.gz See the README for additional information. Sybtcl 2.5 supports Tcl 8.0.



Oratcl

New!! - Oratcl 2.6b1

Scriptics Corp is helping to produce Oratcl 2.6. Included is build support for Oratcl 8.0 & 8.1 versions, and I18N support for Tcl 8.2. You can get the most recent code from Scriptics' NetCVS site, or just download a recent snapshot.

New - Makefile for Oracle 8.0.x

I have received and interim Makefile for Oratcl-2.5 and Oracle 8.0.x. Until Oratcl-3.0 is released which will include Oracle 8 bild support, try this Makefile. (I've received another Oracle 8 makefile to try if you're having problems with the other one, try it here .) Note that you will likely have edit adjust some directory paths before running make. Thanks to Martin Vetter for this Makefile.

Oratcl is a Tcl extension that adds an interface to the Oracle relational database system. Oratcl creates several new commands in Tcl to connect to a Oracle server, send SQL statements, fetch return rows, read and write image columns to files, and query return column names, types, and lengths. Oracle PL/SQL procedures can also be executed and output variables accessed. Full access to Oracle server return codes and error message are also available.

I wrote Oratcl after writing Sybtcl, and I used Sybtcl as a model. Not surprisingly, Oratcl shares many features and overall look and feel with Sybtcl.

You can read more about Oratcl in Tcl/Tk Tools.

Here is a small sample of Oratcl code that connects to an Oracle server, sends an SQL query, then prints the results:

 
set logon [oralogon "myoraid/myorapasswd"]
set hand [oraopen $logon]
orasql $hand "select ename, job from emp order by ename"
orafetch $hand {
  puts [format "%s, %s" @1 @2]
}
oralogoff $hand
    

Together with Tk, Oratcl can be a rapid development tool for building X Window based Oracle applications.

The Oratcl distribution includes Wosql, an X Window based SQL processor. A sample screen shot is here (15k). Actually, the screen shot is of Wisqlite, the SQL processor shipped with Sybtcl. Wosql has only cosmetic differences, and Oracle specific functions. All other features of the interface are shared with Wisqlite.

The current version is 2.5 released January, 1998, and can be found at ftp://ftp.procplace.com/pub/tcl/sorted/databases/oratcl-2.5/oratcl-2.5.tar.gz
See the README for additional information. Oratcl 2.5 supports Tcl 8.0.

Current fixes

I've had reports that some systems have trouble building Oratcl as a shared library. In that case, try building static libraries and executables, configure options --disable-shared


TclRobots

TclRobots is a programming game written in, and uses the Tcl language. In TclRobots the idea is to write a Tcl program that controls a robot. Your robot's mission is to seek out and destroy other robots, each running different control programs. TclRobots provides the arena and a library of robot control procedures to scan, drive, fire the cannon, etc.

A sample screen shot is here (15k).

Here is a sample TclRobots control program. This program takes the strategy of finding an opponent, then driving toward and shooting at the target.


#
# TclRobots - sample robot control program
# Tom Poindexter
#
# charger.tr

set dir [rand 360]
set nothing 0
set closest 0
 
# start of main code
 
while {1} {
 
  # look for an opponet
  set rng [scanner $dir 10]
 
  # if found and inrange
  if {$rng > 0 && $rng < 700} {
 
    # begin narrow scan
    set start [expr ($dir+20)%360]
    for {set limit 1} {$limit <= 40} {incr limit} {
      set dir [expr ($start-($limit)+360)%360]
      set rng [scanner $dir 1]
      if {$rng > 0 && $rng < 700} {
        # fire a shell, and backup scan so not to miss a moving target
        set nothing 0
        # charge!
        cannon $dir $rng
        drive $dir 70
        incr limit -4
      }
    }
  } else {
    incr nothing
    if {$rng > 700} {set closest $dir}
  }
 
  drive 0 0
  # check for nothing found in reasonable time
  if {$nothing >= 30} {
    set nothing 0
    drive $closest 100
    after 10000 drive 0 0
  }
 
  set dir [expr ($dir-20+360)%360]
}


The current version is 2.0 released March, 1996, and can be found at ftp://ftp.procplace.com/pub/tcl/sorted/games/tclrobots-2.0/tclrobots-2.0.tar.gz
TclRobots is currently based on Tcl 7.6 and Tk 4.2.

I sponsored a TclRobots tournament on the net September, 1994, and again in May, 1996. Results of the first two TclRobots Challenges are in ftp://ftp.procplace.com/pub/tcl/sorted/misc/TclRobots/


Tcl-my-fancy

Tcl-my-fancy is a simple /bin/sh based tool that aids in the building of Tcl and Tk interpreters that include serveral extensions. Tcl-my-fancy searches sibling directories for the Tcl, Tk, and optionally, Extended Tcl libraries, finds extension libraries (such as Sybtcl, Oratcl, Tcl-DP, BLT, etc.), and tries to determines the initialization function for the extension library. Finally, the tclAppInit.c files are created to call each extension's initialization function, and builds a Makefile that includes all requested extensions.

The current version is 3.0 released March, 1998, and can be found at ftp://ftp.procplace.com/pub/tcl/sorted/packages-7.6/devel/tcl-my-fancy-3.0.tar.gz .
For more information, check the README.

Tcl-my-fancy is NOT associated with the Make-A-Wish Foundation of America, Inc.
Tcl-my-fancy is currently based on Tcl 8.0 and Tk 8.0.


MSTCL7.3

MSTCL is a port of Tcl 7.3, Tk 4.0, and TclX 7.3a to MS-DOS. The Tk wish executable requires Desqview/X from
Quarterdeck to run. The command line executables tclsh and tcl (/w Extended Tcl) interpreters run under vanilla MS-DOS. The DJ GNU C compiler was used for the port, providing a flat 32 bit environment. Minimal support for Tcl's 'exec' is provided as a shell to MS-DOS.

The port is unsupported and was released December, 1993, and can be found at ftp://ftp.procplace.com/pub/tcl/sorted/distrib/mstcl73s.zip for source and ftp://ftp.procplace.com/pub/tcl/sorted/distrib/mstcl73e.zip for executables.
README has additional information and porting notes. If you are looking to run Tcl/Tk under Windows, see Sun's Tcl/Tk. home page for the official Windows (and Mac) ports.


Mpexpr

Mpexpr is a multiple precision math package for Tcl. Mpexpr adds two new commands to Tcl: mpexpr and mpformat. mpexpr is used just like Tcl's expr command, except it allows you to calculate with ridiculously large numbers. Or ordinary average size numbers, without the binary floating point to decimal floating point conversion problems that expr sometimes experiences.

For example:

% set mp_precision 50
50
% mpexpr 2.0/3.0
0.66666666666666666666666666666666666666666666666667
% mpexpr atan(1.0)*4                        ;# common pi approximation
3.14159265358979323846264338327950288419716939937511
% mpexpr fact(34)                           ;# factorial
295232799039604140847618609643520000000

Mpexpr is based on Tcl's expr command, and David Bell's fine Calc program, which is now enhanced and maintained by Landon Curt Noll.

The current release of Mpexpr is 1.0, and can be found at ftp://ftp.procplace.com/pub/tcl/sorted/math/Mpexpr-1.0/1.0/mpexpr-1.0.tar.gz . Here is the README. Mpexpr supports Tcl 8.0


Fcgi.tcl

Fcgi.tcl is a Tcl interface for the
FastCGI protocol. FastCGI is a web server-neutral API for server side programming. You can think of FastCGI as persistent CGI; FastCGI programs start up once and serve CGI requests without having to restart for each new request. FastCGI's nice feature is that common CGI programs can be converted to FastCGI programs with very little work.

Fcgi.tcl comes in two flavors: a 100% Tcl flavor, and a C extension flavor. Both flavors offer the same programming interface for Tcl CGI programs.

Fcgi.tcl is designed to work with Don Libes' excellent cgi.tcl package.

Here is an example FastCGI program that echoes the CGI environment. It also uses cgi.tcl.

#!/bin/sh
# restart using tcl \
 exec /usr/local/bin/tclsh8.0 "$0" "$@"
#
#  echo-cgi --
# 
package require cgi
package require Fcgi
 
set count 0 
while {[FCGI_Accept] >= 0 } {
  cgi_eval {
    incr count
    cgi_title "fcgi.tcl: echo-cgi.fcg"
    cgi_body {
      cgi_h1 "fcgi.tcl"
      cgi_h2 "echo-cgi.fcg: request number $count"
      cgi_parray env
    }
  }
}

You will also need a web server that support FastCGI, such as Apache compiled with the mod_fastcgi module. Other web servers support FastCGI (Netscape, NCSA, etc.); see the Fcgi.tcl README for additional pointers.

The current release of Fcgi.tcl is 0.4, and can be found at ftp://ftp.procplace.com/pub/tcl/sorted/net/fcgi.tcl-0.4/fcgi.tcl-0.4.tar.gz . Here is the README. Fcgi.tcl supports Tcl 8.0


Sockspy

Sockspy is a TCP convesation debugger. It sits between a TCP client and server, and displays the data streams from each endpoint. Sockspy runs on Unix or MS-Windows.

The current release of Sockspy is 1.0, and can be found at ftp://ftp.procplace.com/pub/tcl/sorted/net/sockspy-1.0/1.0/sockspy-1.0.tar.gz

A sample screen shot is here (37k). This snapshot show sockspy examining the HTTP protocol between Netscape and a web site.

Here is the README


TclTicker

TclTicker is a simple stock market ticker. It runs on Unix or Windows. TclTicker also includes mailquote, a program to mail stock quotes to email addresses.

The current release of TclTicker is 1.3, and can be found at ftp://ftp.procplace.com/pub/tcl/sorted/apps/tclticker/1.3/tclticker-1.3.tar.gz

A sample screen shot is here (11k). TclTicker's configuration window is opened.

Here is the README

Another stock ticker application you might want to check out is Show Me the Money (also known as "smtm".) It's written by Dirk Eddelbuettel .


Odbcisql

Odbcisql is a SQL processor for ODBC connected databases. It is based on my wisqlite and wosql programs from my Sybtcl and Oratcl packages.

A sample screen shot is here (15k) (Ok, this is really wisqlite from Sybtcl, but odbcisql looks basically the same.)

The current release of Odbcisql is 1.0, and can be found at ftp://ftp.procplace.com/pub/tcl/sorted/databases/odbcisql/1.0/odbcisql-1.0.tar.gz

Here is the README


Back to Tom Poindexter's Home Page.
Last updated: December 28, 1999