Hi all, i am new on this forum and i am "almost" new about tcl/tk.
OK, my question is simple:
i have write a simple script to count from 0 to any positive number; please read following:
#A simple script that make possible to count from 0 up to given positive number
proc main {} {
puts -nonewline "Insert a positive number: ";
flush stdout;
gets stdin upTo;
if {$upTo<=0} {
puts "Error";
main;
}
for {set count 0} {$count<=$upTo} {incr count} {
puts "$count";
}
}
main;
If i make an error and insert a negative number, it tell me "error" then repeat the main proc again but if i insert a char, or a string, it does not tell me any error and it counts apparently up to infinity. Why?
OK, my question is simple:
i have write a simple script to count from 0 to any positive number; please read following:
#A simple script that make possible to count from 0 up to given positive number
proc main {} {
puts -nonewline "Insert a positive number: ";
flush stdout;
gets stdin upTo;
if {$upTo<=0} {
puts "Error";
main;
}
for {set count 0} {$count<=$upTo} {incr count} {
puts "$count";
}
}
main;
If i make an error and insert a negative number, it tell me "error" then repeat the main proc again but if i insert a char, or a string, it does not tell me any error and it counts apparently up to infinity. Why?