I'm looking for the equivalent of python's
if __name__ == "__main__":
Would it be
if {[info frame] == 1} {...
?
--
Glenn Jackman
Write a wise saying and your name will live forever. -- Anonymous
To answer my own question, that is incorrect.
The correct answer:
if {[info script] eq $::argv0} ...
Also, it seems that [info frame] returns 2 when inside the if condition
$ cat frame.tcl
set f1 [info frame]
if {[set f2 [info frame]] == 1} {
puts "in frame 1"
} else {
puts "f1=$f1"
puts "f2=$f2"
}
$ tclsh85 frame.tcl
f1=1
f2=2