#!/usr/bin/tclsh
proc keypressed {{channel stdin}} {
exec /bin/stty raw -echo <@stdin
set c [read stdin 1]
exec /bin/stty -raw echo <@stdin
}
set k 0
puts "select example number"
gets stdin example
if {$example ==1} {
for {set i 0} {$i<= 10} {set i [expr {$i +1}]} {
set k [expr {$k+$i}]
puts $k
keypressed
}
puts "k=$k \nend of program"
exit
}
#placement of "set z '"" really maters, by chamging position result will changed"
if {$example !=1} {#if u put set z"" here result will be different
for {set i 1} {$i<= 5} {incr i} {set z ""
for {set k 1} {$k<=5} {incr k} {
set z "*$z" }
puts $z
keypressed }
puts "end of program"
exit
}
proc keypressed {{channel stdin}} {
exec /bin/stty raw -echo <@stdin
set c [read stdin 1]
exec /bin/stty -raw echo <@stdin
}
set k 0
puts "select example number"
gets stdin example
if {$example ==1} {
for {set i 0} {$i<= 10} {set i [expr {$i +1}]} {
set k [expr {$k+$i}]
puts $k
keypressed
}
puts "k=$k \nend of program"
exit
}
#placement of "set z '"" really maters, by chamging position result will changed"
if {$example !=1} {#if u put set z"" here result will be different
for {set i 1} {$i<= 5} {incr i} {set z ""
for {set k 1} {$k<=5} {incr k} {
set z "*$z" }
puts $z
keypressed }
puts "end of program"
exit
}
No comments:
Post a Comment