Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword or section
Like this
28Activity
0 of .
Results for:
No results containing your search query
P. 1
TCL-tutorial

TCL-tutorial

Ratings: (0)|Views: 1,352|Likes:
Published by carragher

More info:

Published by: carragher on Sep 04, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

05/09/2014

pdf

text

original

 
Tcl Tutorial
Introduction 
Simple Text Output 
Assigning values to variables 
Evaluation & Substitutions 1: Grouping arguments with "" 
Evaluation & Substitutions 2: Grouping arguments with {} 
Evaluation & Substitutions 3: Grouping arguments with [] 
Results of a command - Math 101 
Numeric Comparisons 101 - if  
Textual Comparison - switch 
Looping 101 - While loop 
Looping 102 - For and incr 
Adding new commands to Tcl - proc 
Variations in proc arguments and return values 
Variable scope - global and upvar 
Tcl Data Structures 101 - The list 
Adding & Deleting members of a list 
More list commands - lsearch, lsort, lrange 
String Subcommands - length index range 
String comparisons - compare match first last wordend 
Modifying Strings - tolower, toupper, trim, format 
Regular Expressions 101 
More Examples Of Regular Expressions 
More Quoting Hell - Regular Expressions 102 
Associative Arrays 
More On Arrays - Iterating and use in procedures 
File Access 101 
Information about Files - file, glob 
Invoking Subprocesses from Tcl - exec, open 
Learning the existence of commands and variables ? - info 
State of the interpreter - info 
Information about procs - info 
Modularization - source 
Building reusable libraries - packages and namespaces 
Creating Commands - eval 
More command construction - format, list 
Substitution without evaluation - format, subst 
Changing Working Directory - cd, pwd 
Debugging & Errors - errorInfo errorCode catch error return 
More Debugging - trace 
Command line arguments and environment strings 
Leftovers - time, unset 
Channel I/O: socket, fileevent, vwait 
Time and Date - clock 
More channel I/O - fblocked & fconfigure 
Child interpreters 
 
Introduction
Index
|
Next lesson
 Welcome to the Tcl tutorial. We wrote it with the goal of helping you to learn Tcl. It is aimed atthose who have some knowledge of programming, although you certainly don't have to be anexpert. The tutorial is intended as a companion to the Tcl manual pages which provide areference for all Tcl commands.It is divided into brief sections covering different aspects of the language. Depending on whatsystem you are on, you can always look up the reference documntation for commands that youare curious about. On Unix for example,
man while
would bring up the man page for the
while
 command.Each section is accompanied by relevant examples showing you how to put to use the materialcovered.
Additional Resources
The Tcl community is an exceedingly friendly one. It's polite to try and figure things outyourself, but if you're struggling, we're more than willing to help. Here are some good places toget help:
The comp.lang.tcl newsgroup. Accessible via a newsreader, or Google Groups.
TheWikihas a great deal of useful code, examples and discussions of the finer points of Tcl usage.
If you need help right away, there is often someone on the #tcl channel onirc.freenode.net who can help you out, but please don't be impatient if no one can helpyou instantly - if you need that level of support, consider hiring a consultant.
There are several recommended books for those who wish to gain more in-depthknowledge of Tcl.Clif Flynt, the original author of this tutorial is also the author of Tcl/Tk: A Developer's Guide. Other popular books:Practical Programming in Tcl and Tk.
Credits
Thanks first and foremost to Clif Flynt for making his material available under a BSD license.The following people also contributed:
Neil Madden
Arjen Markus
David N. Welton Of course, we also welcome comments and suggestions about how it could be improved - or if it's great the way it is, we don't mind a bit of thanks, either!
Index
|
Next lesson
 
 
Simple Text Output
Previous lesson
|
Index
|
Next lesson
 The traditional starting place for a tutorial is the classic "Hello, World" program. Once you canprint out a string, you're well on your way to using Tcl for fun and profit!The command to output a string in Tcl is the
puts
command.A single unit of text after the
puts
command will be printed to the standard output device (inthis case, the lower window). The default behavior is to print a newline character ("return")appropriate for the system after printing the text.If the string has more than one word, you must enclose the string in double quotes or braces({}). A set of words enclosed in quotes or braces is treated as a single unit, while wordsseparated by whitespace are treated as multiple arguments to the command. Quotes andbraces can both be used to group several words into a single unit. However, they actuallybehave differently. In the next lesson you'll start to learn some of the differences between theirbehaviors.
Note
that in Tcl, single quotes are not significant, as they are in other programminglanguages such as C, Perl and Python.Many commands in Tcl (including
puts
) can accept multiple arguments. If a string is notenclosed in quotes or braces, the Tcl interpreter will consider each word in the string as aseparate argument, and pass each individually to the
puts
command. The
puts
command willtry to evaluate the words as optional arguments. This will probably result in an error.A command in Tcl is a list of words terminated by a newline or semicolon. Tcl comments are a
#
 at the beginning of the line, or after the command is closed with a
;
semicolon.
Example
puts "Hello, World - In quotes" ;# This is a comment after the command.puts {Hello, World - In Braces} # *Error* - there is no semicolon!puts "This is line 1"; puts "this is line 2"puts "Hello, World; - With a semicolon inside the quotes"
Previous lesson
|
Index
|
Next lesson
 

Activity (28)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Kiran Rekhi liked this
Luca Colombini liked this
boopathi2k3 liked this
nambiar123 liked this
Viorel Costache liked this
Chen Y'Lun liked this
const_l liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->