Re: foreach problem
- From: "Hans Herrmann" <lieber@xxxxxxxxxxxxxxx>
- Date: Sun, 5 Jun 2005 21:33:55 +0200
"Darren New" <dnew@xxxxxxxxxx> schrieb im Newsbeitrag
news:68Ioe.41400$ya2.26287@xxxxxxxxxxxxxxxxxxxxxxx
> Hans Herrmann wrote:
>> Hi all,
>> I know its simple but ...???
>>
>> set l 1,0
>> set b 2,0
>>
>> foreach pos {l b} {
>
> Here, pos takes on the values of "l" and "b".
>
>> resub -all {,} $pos {.} pos
>
> So here, you're substituting periods for commas in "l" and "b", and
> assigning the result to pos.
>
> What you probably want is another level of look-up-the-variable, so the
> regsub line should be
>
> regsub -all {,} [set $pos] {.} [set pos]
>
> The first time thru the loop, [set pos] returns "l" and [set $pos] returns
> "1,0". SO this translates to
> regsub -all , 1,0 . l
> which is what you want.
>
> Basically, when you're looping over the names of variables, you have to
> put an extra indirection in there.
>
> HTH.
>
Hi Darren,
many thanks for your help!
Hans
.
- References:
- foreach problem
- From: Hans Herrmann
- Re: foreach problem
- From: Darren New
- foreach problem
- Prev by Date: Re: foreach problem
- Next by Date: Re: charting
- Previous by thread: Re: foreach problem
- Next by thread: Re: foreach problem
- Index(es):
Relevant Pages
|