Hi,
My code uses try_eval block to do some code execution. This piece of code does not work on RHEL 5.4. The program just hangs at the try_eval block and does not throw any errors either. The same program however works in other Linux boxes that we have.
I have written a simple program that uses try_eval as below. However, when i try to run the program it throws an "invalid command name". I am stuck and unable to move further. Any help/pointers on what i am doing incorrectly would be of great help !
package provide temp 1.0
namespace export temp
package require Itcl
namespace import -force ::itcl::*
set a "some var"
puts "$a"
class temp {
public method getEntry {} {
try_eval {
# code
puts -nonewline stderr "Enter a number: "
set ans [gets stdin]
set res [expr 1.0 + $ans]
puts stderr "1 + $ans = $res"
} {
# catch
set msg [lindex $errorCode end]
puts stderr "Error: $msg"
} {
# finally
puts stderr "End of example"
}
}
}
variable tempObj
set tempObj [temp #auto]
puts "$tempObj"
set res [$tempObj getEntry]
puts "$res"
On running this i get the below error:
$tclsh temp.tcl
some var
temp0
invalid command name "try_eval"
while executing
"try_eval {
# code
puts -nonewline stderr "Enter a number: "
set ans [gets stdin]
set res [expr 1.0 + $ans]
puts stderr "1 ..."
(object "::temp0" method "::temp::getEntry" body line 4)
invoked from within
"$tempObj getEntry"
invoked from within
"set res [$tempObj getEntry]"
(file "temp.tcl" line 43)
I am using tcl version tcl8.4