Reference

   

Practical Programming in Tcl & Tk, Third Edition
By Brent B. Welch

Table of Contents
Chapter 1.  Tcl Fundamentals


Backslash Sequences

Table 1-1. Backslash sequences.
\aBell. (0x7)
\bBackspace. (0x8)
\fForm feed. (0xc)
\nNewline. (0xa)
\rCarriage return. (0xd)
\tTab. (0x9)
\vVertical tab. (0xb)
\<newline>Replace the newline and the leading white space on the next line with a space.
\\Backslash. ('\')
\oooOctal specification of character code. 1, 2, or 3 digits.
\xhhHexadecimal specification of character code. 1 or 2 digits.
\uhhhhHexadecimal specification of a 16-bit Unicode character value. 4 hex digits.
\cReplaced with literal c if c is not one of the cases listed above. In particular, \$, \", \{, \}, \], and \[ are used to obtain these characters.

Arithmetic Operators

Table 1-2. Arithmetic operators from highest to lowest precedence.
- ~ !Unary minus, bitwise NOT, logical NOT.
* / %Multiply, divide, remainder.
+ -Add, subtract.
<< >>Left shift, right shift.
< > <= >=Comparison: less, greater, less or equal, greater or equal.
== !=Equal, not equal.
&Bitwise AND.
^Bitwise XOR.
|Bitwise OR.
&&Logical AND.
||Logical OR.
x?y:zIf x then y else z.

Built-in Math Functions

Table 1-3. Built-in math functions.
acos(x)Arc cosine of x.
asin(x)Arc sine of x.
atan(x)Arc tangent of x.
atan2(y,x)Rectangular (x,y) to polar (r,th). atan2 gives th.
ceil(x)Least integral value greater than or equal to x.
cos(x)Cosine of x.
cosh(x)Hyperbolic cosine of x.
exp(x)Exponential, ex.
floor(x)Greatest integral value less than or equal to x.
fmod(x,y)Floating point remainder of x/y.
hypot(x,y)Returns sqrt(x*x + y*y). r part of polar coordinates.
log(x)Natural log of x.
log10(x)Log base 10 of x.
pow(x,y)x to the y power, xy.
sin(x)Sine of x.
sinh(x)Hyperbolic sine of x.
sqrt(x)Square root of x.
tan(x)Tangent of x.
tanh(x)Hyperbolic tangent of x.
abs(x)Absolute value of x.
double(x)Promote x to floating point.
int(x)Truncate x to an integer.
round(x)Round x to an integer.
rand()Return a random floating point value between 0.0 and 1.0.
srand(x)Set the seed for the random number generator to the integer x.

Core Tcl Commands

The pages listed in Table 1-4 give the primary references for the command.

Table 1-4. Built-in Tcl commands.
CommandPg.Description
after218Schedule a Tcl command for later execution.
append51Append arguments to a variable's value. No spaces added.
array91Query array state and search through elements.
binary54Convert between strings and binary data.
break77Exit loop prematurely.
catch77Trap errors.
cd115Change working directory.
clock173Get the time and format date strings.
close115Close an open I/O stream.
concat61Concatenate arguments with spaces between. Splices lists.
console28Control the console used to enter commands interactively.
continue77Continue with next loop iteration.
error79Raise an error.
eof109Check for end of file.
eval122Concatenate arguments and evaluate them as a command.
exec99Fork and execute a UNIX program.
exit116Terminate the process.
expr6Evaluate a math expression.
fblocked223Poll an I/O channel to see if data is ready.
fconfigure221Set and query I/O channel properties.
fcopy239Copy from one I/O channel to another.
file102Query the file system.
fileevent219Register callback for event-driven I/O.
flush109Flush output from an I/O stream's internal buffers.
for76Loop construct similar to C for statement.
foreach73Loop construct over a list, or lists, of values.
format52Format a string similar to C sprintf.
gets112Read a line of input from an I/O stream.
glob115Expand a pattern to matching file names.
global84Declare global variables.
history185Use command-line history.
if70Conditional command. Allows else and elseif clauses.
incr12Increment a variable by an integer amount.
info176Query the state of the Tcl interpreter.
interp276Create additional Tcl interpreters.
join65Concatenate list elements with a given separator string.
lappend61Add elements to the end of a list.
lindex63Fetch an element of a list.
linsert64Insert elements into a list.
list61Create a list out of the arguments.
llength63Return the number of elements in a list.
load609Load shared libraries that define Tcl commands.
lrange63Return a range of list elements.
lreplace64Replace elements of a list.
lsearch64Search for an element of a list that matches a pattern.
lsort65Sort a list.
namespace203Create and manipulate namespaces.
open110Open a file or process pipeline for I/O.
package165Provide or require code packages.
pid116Return the process ID.
proc81Define a Tcl procedure.
puts112Output a string to an I/O stream.
pwd115Return the current working directory.
read113Read blocks of characters from an I/O stream.
regexp148Match regular expressions.
regsub152Substitute based on regular expressions.
rename82Change the name of a Tcl command.
return80Return a value from a procedure.
scan54Parse a string according to a format specification.
seek114Set the seek offset of an I/O stream.
set5Assign a value to a variable.
socket228Open a TCP/IP network connection.
source26Evaluate the Tcl commands in a file.
split65Chop a string up into list elements.
string45Operate on strings.
subst132Substitute embedded commands and variable references.
switch71Multi-way branch.
tell114Return the current seek offset of an I/O stream.
time191Measure the execution time of a command.
trace183Monitor variable assignments.
unknown167Handle unknown commands.
unset13Delete variables.
uplevel130Execute a command in a different scope.
upvar85Reference a variable in a different scope.
variable197Declare namespace variables.
vwait220Wait for a variable to be modified.
while73Loop until a boolean expression is false.


       
    Top
     



    Practical Programming in Tcl and Tk
    Practical Programming in Tcl and Tk (4th Edition)
    ISBN: 0130385603
    EAN: 2147483647
    Year: 1999
    Pages: 478

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net