Reputation: 67
I wrote a script that need to work inside tool. When sourcing the file I want "checker" proc will drop the entire sourcing if $current > $exp The problem is a inner command inside the tool call "exit" and this command cause tool to exit. How can I implement it? I tried instead of "exit" use "error" but it print additional errors and don't stop my script clearly.
proc checker {} {
set current 100
set exp 50
if {${current} > ${exp}} {
exit
}
}
checker
puts "done!!"
Upvotes: 0
Views: 541
Reputation: 1873
A return
statement in a script will stop sourcing a script.
When you're in the proc, you can use return -level <integer>
to return not only from the proc, also from a higher level in the call stack.
This is equivalent to using the uplevel
command to execute a command at higher level in the call stack.
Upvotes: 3