Vous êtes sur la page 1sur 2

switch -glob $argv {

w* {puts Wipro}
a[3-7] {puts "XYZ"}
default {puts {no match}}
}
wild character:
Can we have multiple versions of interpreter? Ans: Yes
What interpreter will be in use if we install 8.6 first and 8.4 last. only the l
ast version will be used
as interpreter.
Also if multiple versions are running then
if tclsh a.tcl ( 8.4 is used)
if tclsh84 a.tcl (8.4 is used)
if tclsh86 a. tcl (8.6 is used)
in case both are available
--------------------------------------------
-- if preceeded with then it will not take other flag as flag as
it marks end of flag
--------------------------------------------------
foreach command
---------------
foreach takes three arguments
foreach value { 45 77 99 yy 6 2} {
puts $value
}
for command
-----------
for command takes 4 arguments
eg
-----------------------------------
Logical Operator
---------------
numbers only as operand
&&, || and !
each operator produces either a 0 or 1 their result
Ternary Operator
----------------
expr { (exp1) ? (exp2): (exp3) }
set a 100
set b 500
set c
Math functions
--------------
e.g.
set a [ expr pow(2,3)]; # 2 raised to 3
puts $a o/p: 8
Types and conversions
---------------------
tcl evaluates expressions numerically whenever possible
strin

Precision
----------
predefined variable : tcl_precision
set a [expr 1.222222222222222222222222222+1.11111111111111111111111111111111]
puts $a
default precesion in 8.4 is 12 places
default precesion is 8.6 is 17 places
set tcl_precision 5 # it will give 5 place precision

STRING
-------
group of character and it always terminated by null
format command
format spec value1 value2 ....
scan command
scan 1uy78ijk %d%s var1 var2
Home Work
How to add two octal number in TCL?

Vous aimerez peut-être aussi