Search the Catalog
Tcl/Tk in a Nutshell

Tcl/Tk in a Nutshell

By Paul Raines & Jeff Tranter
1st Edition March 1999
1-56592-433-9, Order Number: 4339
456 pages, $24.95

Sample Chapter 10:

TclX

Contents:
Special Variables
Group Listing of Commands
Alphabetical Summary of Commands

TclX, also known as Extended Tcl, was developed by Karl Lehenbauer and Mark Diekhans. TclX is not part of the core Tcl/Tk package, but can be obtained for free at http://www.neosoft.com/TclX. This chapter covers TclX Version 8.0.2.

TclX enhances the Tcl language with a number of features designed to make it more suited to general-purpose programming. The TclX software includes a number of new Tcl commands, a new Tcl shell, a standalone help facility, and a library of handy Tcl procedures. Some features of TclX have proven so useful that, over time, they have been integrated into the core Tcl distribution.

This chapter describes only the commands in TclX that are not in standard Tcl. As noted in the text, some commands are not supported or have reduced functionality when running on the Windows 95, Windows 98, and Windows NT platforms. TclX does not support the Macintosh platform.

10.1 Special Variables

The following global variables have special meaning to the Extended Tcl interpreter (the programs tcl and wishx):

argc

Number of command-line arguments, not including the name of the script file

argv

List containing command-line arguments

argv0

Filename being interpreted, or name by which script was invoked

auto_path

Path to search to locate autoload libraries

tcl_interactive

1 if running interactively, 0 otherwise

tcl_prompt1

Primary prompt

tcl_prompt2

Secondary prompt for incomplete commands

tclx_library

Location of Extended Tcl libraries

tkx_library

Location of Extended Tcl Tk libraries

TCLXENV

Array containing information about Tcl procedures

10.2 Group Listing of Commands

This section briefly lists all Extended Tcl commands, grouped logically by function.

10.2.1 General Commands

commandloop Create an interactive command loop.
dirs List directories in directory stack.
echo Write strings to standard output.
for_array_keys Loop over each key in an array.
for_recursive_glob Loop recursively over files matching a pattern.
host_info Return information about a network host.
infox Return information about Extended Tcl.
loop Loop over a range of values.
mainloop Call event loop handler.
popd Pop top entry from the directory stack.
pushd Push entry onto directory stack.
recursive_glob Return list of files recursively matching pattern.
tclx_errorHandler User-defined procedure to handle errors.
try_eval Evaluate code and trap errors.

10.2.2 Debugging and Development Commands

cmdtrace Trace command execution.
edprocs Edit source code for procedures.
profile Collect performance data.
profrep Generate report from performance data.
saveprocs Save procedure definitions to file.
showproc List definitions of procedures.

10.2.3 Unix Access Commands

alarm Send alarm signal.
chroot Change root directory.
execl Start a new program.
fork Create a child process.
id Set, get, or convert user, group, and process identifiers.
kill Send signal to a process.
link Create a hard or symbolic link.
nice Set or get process priority.
readdir Return list of directory entries.
signal Handle Unix signals.
sleep Delay process execution.
sync Flush pending buffered output.
system Execute shell command.
times Return process and child execution times.
umask Set or get file creation permission mask.
wait Wait for command to terminate.

10.2.4 File Commands

bsearch Search lines of file for a string.
chgrp Set group ID of files.
chmod Set file permissions.
chown Set owner of files.
dup Duplicate an open file identifier.
fcntl Set or get attributes of file identifier.
flock Apply lock on an open file.
for_file Loop over contents of a file.
fstat Return status information about an open file identifier.
ftruncate Truncate a file to a specified length.
funlock Remove lock from an open file.
lgets Read Tcl list from a file.
pipe Create a pipe.
read_file Read file contents into a string.
select Check file identifiers for change in status.
write_file Write strings to a file.

10.2.5 File Scanning Commands

scancontext Create, delete, or modify file scan contexts.
scanfile Perform file context scanning.
scanmatch Specify commands for file context scanning.

10.2.6 Math Commands

These commands operate in the same fashion as their counterparts that are built into the expr command. They accept as arguments any expression accepted by the expr command. The trigonometric functions use values expressed in radians.

abs Absolute value.
acos Arc cosine.
asin Arc sine.
atan Arc tangent.
atan2 Arc tangent (accepts two parameters).
ceil Round up to the nearest integer.
cos Cosine.
cosh Hyperbolic cosine.
double Convert numeric value to double-precision floating-point value.
exp e raised to the power of the argument.
floor Round down to the nearest integer.
fmod Floating-point remainder (accepts two arguments).
hypot Hypotenuse function (accepts two arguments).
int Convert to integer by truncating.
log Natural logarithm.
log10 Base 10 logarithm.
max Maximum value (accepts one or more arguments).
min Minimum value (accepts one or more arguments).
pow Exponentiation (accepts two parameters).
random Return random floating-point number.
round Convert to integer by rounding.
sin Sine.
sinh Hyperbolic sine.
sqrt Square root.
tan Tangent.
tanh Hyperbolic tangent.

10.2.7 List Manipulation Commands

intersect Return list of elements common to two lists.
intersect3 Accept two lists, returning items common to, and unique to, each list.
lassign Assign list elements to variables.
lcontain Return 1 if element is contained in a list.
lempty Return 1 if a list is empty.
lmatch Search list for elements matching a pattern.
lrmdups Remove duplicate list elements.
lvarcat Concatenate lists onto a variable.
lvarpop Delete or replace list element contained in a variable.
lvarpush Insert element into list contained in a variable.
union Return logical union of two lists.

10.2.8 Keyed List Commands

keyldel Delete entry from keyed list.
keylget Return value from keyed list.
keylkeys Return list of keys from keyed list.
keylset Set value in keyed list.

10.2.9 String and Character Manipulation Commands

ccollate Return collation ordering of two strings.
cconcat Concatenate strings.
cequal Compare strings for equality.
cindex Return one character from a string.
clength Return length of a string.
crange Return range of characters from a string.
csubstr Return substring of a string.
ctoken Parse a token out of a string.
ctype Return type of characters in a string.
replicate Replicate a string several times.
translit Transliterate characters in a string.

10.2.10 XPG/3 Message Catalog Commands

catclose Close a message catalog.
catgets Retrieve message from a catalog.
catopen Open a message catalog.

10.2.11 Help Commands

apropos Locate help information based on a pattern.
help Online help system for Extended Tcl.
helpcd Change current location in tree of help subjects.
helppwd List current help subject location.

10.2.12 Library and Package Commands

auto_commands List names of loadable commands.
auto_load_file Source a file using autoload path.
auto_packages Return names of defined packages.
buildpackageindex Build index files for package libraries.
convert_lib Convert Tcl index and source files into a package.
loadlibindex Load a package library index.
searchpath Search a path of directories for a file.

10.3 Alphabetical Summary of Commands

This section describes all Extended Tcl commands, listed in alphabetical order.

Continue this chapter...


oreilly.com Home | O'Reilly Bookstores | How to Order | O'Reilly Contacts
International | About O'Reilly | Affiliated Companies | Privacy Policy

© 2001, O'Reilly & Associates, Inc.