TclX

TclX, or Extended Tcl, provides access to the features exposed by API of POSIX systems such Unix.

Attributes

FlightAware hosts a github repository for an updated TclX. The repository describes itself as "Official home of the TclX extension for Tcl", and is currently working on version 8.6 of TclX.

flightaware site
https://github.com/flightaware/tclx
another fork
https://chiselapp.com/user/pooryorick/repository/tclx
old website
http://tclx.sf.net/ (last release 8.4.1 dated 2012-11-07)

Description

This package provides:

  • advanced code loading facility,
  • new programming constructs,
  • debugging and profiling facilities,
  • unix access commands,
  • file I/O facilities including awk-like scanning for strings,
  • extended list and a new key list capability,
  • extended character and string manipulation commands, and
  • time and date manipulation commands.

TclX is oriented towards system programming tasks and large application development. It provides a variety of additional interfaces to the underlying operating system, as well as many new programming constructs, text manipulation tools, and debugging capabilities.

Over the years, a variety of features originally appeared in TclX, and then, as the ideas were proven, migrated to the Tcl core. These features include:

  • Tcl's I/O system,
  • its associative arrays,
  • Internet networking interfaces,
  • upvar,
  • memory debugging,
  • incr

TclX includes documentation on:

  • debugging Tcl memory problems,
  • how to use its keyed list data type,
  • manipulating binary structures via handles,
  • a guide to writing Tcl commands in C,
  • a reference manual for the new TclX commands themselves.

(Give an alternate description of TclX as Tcl augmented with POSIX stuff, such as fork, plus other conveniences common among Unixoids, including keyed lists, profiling, signal and kill, ...)

Useful References

On SourceForge it can be found at http://sourceforge.net/projects/tclx

see ftp://ftp.tcl.tk/pub/tcl/nightly-cvs/ for a tar file of the sf.net cvs head .

The ActiveTcl Batteries Included distribution includes TclX.

TclX Future contains discussion about the interface and interaction between Tcl and TclX.

TclX Commands has a list of TclX's commands.

Evolution, State and History

Karl Lehenbauer first wrote TclX, and he and Mark Diekhans maintained it for a long time. In spring 2002, Jeffrey Hobbs is "reforming" TclX, although he doesn't "own" it.

JH: TclX was not always an extension as it currently is. Before 8.4.0 released on Nov 21, 2005, there was a TkX (aka wishx) component or stand-alone binary ('tcl' exe) support, and was not portable and clean as it is nowadays.

Replacement for wishx

Put this script, called wishx and marked executable, in your path:

#!/bin/sh
#\
exec wish "$0" ${1+"$@"}
package require Tk
package require Tclx
set argv [lassign $argv argv0]
source $argv0

Note: script fixed by MS after a bug report in clt [L1 ]

LV: I would replace the wish in the above script with tclsh myself. Also note that sometimes, when one installs the Tcl package in one of its variations, instead of a command called tclsh or wish, a version number will be attached to the command name. For instance, one might find they have tclsh8.5.exe installed after installing a package. The simpler tclsh or tclsh.exe are often just shortcuts/symbolic links/copies of the other executable name, and in some cases, may not even exist.

Also, note that the above script won't replace ALL the functionality of the original wishx. That is because in the old days when Tclx installed tcl and wishx, there was an interactive command line command called help that was installed, that provided a relatively simple interface to man page like information. The above script doesn't implement that. Shouldn't make a difference for programs expecting to run using wishx (or tcl) but if you are following an old tutorial from a book or some electronic source, you may notice the difference.

Using tclsh or wish, just use the man command to look up information about tcl sub-commands.


How many people use TclX for Unix System Programming?


See also scanxxx without tclx


DKF: TclX is useful when you're running tclsh in setuid or setgid mode, since its id command can be used to perform the uid/gid changing often required when doing such things.


TR: The manual 'ObjCmdWrite.3' (TclCommandWriting - Writing C language extensions to Tcl) is a nice introduction to writing Tcl commands in C. In the 8.4 version there is an example for the reversal of a list, which is not only incomplete but also wrong. I liked the example as such, so here comes a correct version (not targeted at TclX but Tcl in general):

int
lreverseCmd(ClientData notUsed, Tcl_Interp *interp, int objc,Tcl_Obj *const objv[])
{
    int listObjc, listIndex;
    Tcl_Obj **listObjv;
    char *temp, *resultList;
    Tcl_Obj *newListObjv;
 
    /* Verify argument count.  Since we take only one argument, argument
     * count must be 2 (command plus one argument).
     */
    if (objc != 2) {
        Tcl_WrongNumArgs(interp, 1, objv, "list");
        return TCL_ERROR;
    }
    /* Create an object to handle the new list we're creating */
    newListObjv = Tcl_NewObj();
 
    /* Crack the list at objv[1] into its own count and array of object
     * pointers.
     */
    if (Tcl_ListObjGetElements(interp, objv[1], &listObjc, &listObjv) !=  TCL_OK) {
        return TCL_ERROR;
    }
 
    /* For each element in the source list from last to first, append an
     * element to the new list.
     */
    for (listIndex = listObjc - 1; listIndex >= 0; listIndex--) {
        Tcl_ListObjAppendElement (interp, newListObjv, listObjv[listIndex]);
     }
     Tcl_SetObjResult(interp,newListObjv);
     return TCL_OK;
}

LV: you should submit the above as a bug fix on http://tclx.sf.net/ .

Speaking of which - does anyone know if the TclX code is ever going to be updated so it no longer crashes when tested with tcl 8.5? Bug reports have been submitted. Perhaps the only real problem is in the test suite - it would be nice if the test suite didn't crash tcl though.

List of commands

General

dirscommandloopechoinfoxfor_array_keysfor_recursive_globlooppopdpushdrecursive_globshowproctry_eval

Debugging and Development

cmdtraceedprocsprofileprofrepsaveprocs

Unix Access

alarmexeclchrootforkidkilllinknicereaddirsignalsleepsystemsynctimesumaskwait

File

bsearchchmodchownchgrpdupfcntlflockfor_filefunlockfstatftruncatelgetspiperead_fileselectwrite_file

Network Programming

host_info

File Scanning

scancontextscanfilescanmatch

Math

maxminrandom

List Manipulation

intersectintersect3lassignlcontainlemptylmatchlrmdupslvarcatlvarpoplvarpushunion

Keyed Lists

keyldelkeylgetkeylkeyskeylset

String and Character Manipulation

ccollatecconcatcequalcindexclengthcrangecsubstrctokenctypereplicatetranslit

XPG/3 Message Catalogs

catopencatgetscatclose

Event-Driven Programming

mainloop

Help

helphelpcdhelppwdapropos

Package Library Management

auto_commandsbuildpackageindexconvert_libloadlibindexauto_packagesauto_load_filesearchpath