Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Foreach for TCL List

Tags:

tcl

I would like to ask a question regarding TCL.

Let say I have an instance 111 and under this 3 instances (11100, 11102, 11103) are attached. You may say 11100, 11102, 11103 are id's and then there are names attached to these ids such as A, B, C.

At the moment I got all these ids 11100, 11102, 11103 how can use these ids in loop to iterate in loop for three time so I can find each ids name.

like image 965
Dynamo Avatar asked Sep 03 '25 03:09

Dynamo


1 Answers

This is how you can iterate loop over the ids what you already have,

foreach i {11101 11102 11103} { 
    puts $i 
    ;# do what ever with i
}

Another option what you said is you have three variable A B C,

lappend list $A $B $C
foreach i $list { 
    puts $i 
    ;# do what ever with i
}
like image 93
mf_starboi_8041 Avatar answered Sep 05 '25 23:09

mf_starboi_8041