hi all, i have wrote a simple script that take a number and return
either it is an integer or a float. However, if i make a mistake and
type a char or a string, it goes in crash and esc to prompt command.
My question is simple: how can i to resolve this behaviour? Below it is
my code:
Thanks!
either it is an integer or a float. However, if i make a mistake and
type a char or a string, it goes in crash and esc to prompt command.
My question is simple: how can i to resolve this behaviour? Below it is
my code:
Code:
#############################################################################################
# This script ask for a number then tell you either integer or float and
print its exp form #
#############################################################################################
#
proc main {} {
# ask for a number
puts -nonewline "Insert a number: ";
flush stdout;
gets stdin number;
# check for integer
if {int($number)==$number} {
puts "the number [expr int([format %f $number])] is integer";
} else {
puts "the number [format %f $number] is float";
}
# print exp form
puts "its exponential form is [format %e $number]";
}
# call main
main;