Re: Substitution error?
- From: John Seal <sealj@xxxxxxxxxxxxxxxxx>
- Date: Tue, 31 May 2005 11:22:12 -0500
Eduardo Peña wrote:
set topf [frame $frame.topf]
for {set i 0} {$i < 10} {incr i} {
set a$i [TitleFrame $topf.a$i -text "Title $i"]
pack $a$i
}
The problem is that $a$i is the concatenation of the value of a and the value of i, not the value of a$i. You can't say ${a$i} either, because that'd be the value of a-dollar-i, which doesn't exist.
1. You can get the value of the "contructed" variable name like so:
pack [set a$i]
This allows Tcl to substitute the $i, giving a0, a1..., then gets the value of the constructed variable name.
2. You could get rid of the intermediate variable altogether:
pack [TitleFrame $topf.a$i -text "Title $i"] .
- References:
- Substitution error?
- From: Eduardo Peņa
- Substitution error?
- Prev by Date: Re: TclXSLT question: best approach?
- Next by Date: Re: tdom in solaris activestate ?
- Previous by thread: Re: Substitution error?
- Index(es):