Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Execute Tcl Online

puts "Hello World!"
puts "Hello World!"
puts "Hello World!"
if 0 {
    this is a multiline \
    comment. no content of this will\
    be printed
}
puts "Hello\nconsole"
set myvariable {arun mohit tushar ram munir}
puts [lindex $myvariable 3]
append myvariable " " "manoj"
lappend myvariable "mrityunjay"
puts [lindex $myvariable 6]
puts [lindex $myvariable 5]
append myvariable " " "ram"
lappend myvariable "shyam"
puts [llength $myvariable]
set value1 [lindex $myvariable 7]
puts $value1
set value2 [lindex $myvariable 8]
puts $value2
if {$value1 == $value2} {
    puts "matched"
} else {
    puts "unmatched"
}
set mymarks(english) 90
set mymarks(maths) 98
set mymarks(physics) 90
set mymarks(chemistry) 78
set mymarks(biology) 70
puts [array names mymarks]
puts $mymarks(maths)
set language(0) TCL
set language(1) C
set language(2) perl
set language(3) verilog
set language(4) python
puts $language(4)
puts [array size language]
for {set index 0} {$index < [array size language]} {incr index} {
    puts "language($index): $language($index)"
}
foreach indexs [array names mymarks] {
    puts "mymarks($indexs):$mymarks($indexs)"
}
set tobby "helarious"
puts [string length $tobby]

proc helloworld {a {b 12}} {
    puts "Hello World"
    puts [expr $a + $b]
}

helloworld 7 8
helloworld 8

regexp -nocase {([A-Z]*.([A-Z]*))} "Tcl Tutorial" a b c  
puts "Full Match: $a"
puts "Sub Match1: $b"
puts "Sub Match2: $c"
set tcl_precision 12
set num3 [expr 59.67]
set value4 [split $num3 .]
lassign $value4 \
        real decimal
puts $real
set finalvalue $real
puts $finalvalue
puts [expr {$finalvalue + 1}]

puts "ASHOK REQUIREMENT CHECK"
regexp {([0-9]*\.([0-9]*))} "59.64" a b c  
puts "Full Match: $a"
set myvalue [ split $a .]

lassign $myvalue \
        realvalue decimalvalue
puts $realvalue
set  vrealvalue $realvalue
if {$real == $realvalue} {
    puts "matched number"
} else {
    puts " unmatched numbers"
}
puts [expr {$vrealvalue + 1}]
set data {cricket football drawing movies music food}
set hobbies [join $data ", "]
puts "i like $hobbies"

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.