RosettaCodeData/Task/Determine-if-a-string-is-numeric/Tcl/determine-if-a-string-is-numeric-2.tcl
2025-08-11 18:05:26 -07:00

17 lines
269 B
Tcl

# will output an error message
# and quit
proc fatal {msg} {
puts stderr "$msg"
exit 1
}
# a bad string
set x 174gg.4
try {
set n [expr {double($x)}]
set n [expr {int($x)}]
puts $x
} on error { error options } {
fatal "$::errorInfo"
}