TCL is one of the few languages allowing you to dabble in to and one of the few that caught hook with me. It's friendliness then leads you down a path of voodoo and creativity.
proc displayHackerNews {} {
set hn "Hacker News" ;#Fill the variable (hn) with the string "Hacker News"
puts $hn ;#output the variable ($hn) to terminal
} ;#end procedure
displayHackerNews ;#execute the procedure
displays: Hacker News
If statements are easy
set hn ""
if { $hn eq "Hacker News" } { puts $hn } else {
set hn "Not Hacker News"
puts $hn
} ;#end if
Infinite Loops are fun
set hn "Hacker News" ;#Set a variable
while { $hn eq "Hacker News" } {
puts "$hn" ;# print "Hacker News" to terminal in an infinite loop
} ;#end loop
Multi-threading is a breeze.
package require Thread
set MyThreadID [thread::create {
puts "Hello from my new thread"
thread::wait
} ;#end code-to-run
] ;#end thread
And finally, a if-switch-threaded-loop
set hn "Hacker News"
if { $hn eq "Hacker News" } {set switch "hn" } else { set switch "" }
switch $switch {
hn {
set MyThreadID [thread::create {
proc displayHackerNews {} {set hn "Hacker News" ; puts $hn} ;#end procedure
#set aCounter to zero, if aCounter is < 7 execute displayHackerNews procedure
for {set aCounter 0} {$aCounter < 7} {incr aCounter} { displayHackerNews }
thread::wait
} ;#end threaded-code
] ;#end thread
} ;#end switch-case
default {puts "It's still not hacker news"}
} ;#end switch