OK -- here is an interesting question.
I am using struct (tree - tcllib) on 8.4.1/2 and have found it a nice
addition to the toolbox for structuring data.
However, when I am walking through the tree and want to stop the walk
-- I can not seem to do it without causing a major error. I was
trying to add a "break" to the command loop - but it did not work as
expected.
I am using something similar to:
myTree walk $startNode -command {
if {"%n" == "0.7"} {
break ; # Get out of the walk!
} else {
.tb insert end "WALKED TO THIS: %n\n"
}
}
Note: "return" does not seem to do the trick either - and I really
would not like to use the return as I am trying to use this walk code
liek a foreach execept using the tree structure.
Anyone have any suggestions?
Dave
A few months ago, I wanted something similar--to have a "prune" command that
could be called within a walk script. This prune command would continue
walking, but not walk any of the descendents of the current node. After
playing around I found that the following had the behavior I wanted (at
least for depth first walking--I didn't try with any others):
return -code continue
I think if you want to stop the walk altogether, you could use (I haven't
tried this):
return -code break
This is very dependent on how the walk command is currently implemented, so
if it ever changes these may no longer work.
Brian Theado