Dynamo
Dynamo

Reputation: 137

Foreach for TCL List

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.

Upvotes: 3

Views: 25981

Answers (1)

toxic_boi_8041
toxic_boi_8041

Reputation: 1482

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
}

Upvotes: 6

Related Questions