Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

procedure calls 1

Status
Not open for further replies.

Thodd

Technical User
Joined
Oct 21, 2006
Messages
27
Location
BE
Hi,

I'm trying to call serveral procedures in a for-loop, but each cycle of the loop calls another procedure (named procedure0, procedure1,...), like this:

for {set x 0} {$x < 10} {incr x} {
puts "loopcount [expr $x + 1]"
$ns at $x "procedureX"
}

Does someone know how I can do this?
thx
 
Ok thx, it works!
 
You're right feherke.
Tcl also permits array of procedures:
Code:
proc procedure(1) {} { puts "one" }
proc procedure(2) {} { puts "two" }
proc procedure(3) {} { puts "three" }

for {set i 1} {$i<=3} {incr i} { procedure($i) }
No more eval.

ulis
 
Is Ulis's solution a lot faster, instead of using "eval"?
 
Hi

Yes, my measurement says it is 25% faster then my [tt]eval[/tt] based solution. ( I mean, my works 100% time, Ulis's takes only 75% of it. )

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top