Re: Combining a variable with a counter?
- From: Manfred Stelzhammer <stelzhammer@xxxxxxxxxxx>
- Date: Wed, 13 Jul 2005 22:30:26 +0200
Christoph Hörterer schrieb:
Hi, in my script, I got many similar variables task1 task2 task3 task4 ....
I'd like to address them in a loop with something like
$task$i
for $i being a counter that is increased each time.
Do you have an idea how to solve this. My efforts weren't very successful.
Thanks, Christoph Hörterer
Hi Christoph
You have two possibilites. Take a variable.
set task1 "a b c d" set task2 "e f g h"
set nr 1 lindex [set task$nr] 1 ;#the result is "b" set nr 2 lindex [set task$nr] 2 ;#the result is "g"
#or an array
set task(1) "a b c d" set task(2) "e f g h"
set nr 1 lindex task($nr) 1 ;# the result is "b" set nr 2 lindex task($nr) 2 ;# the result is "g"
I would prefere arrays.
Regards Manfred
p.s. Bist du pofi in self-tcl.de? .
- Follow-Ups:
- Re: Combining a variable with a counter?
- From: Christoph Hörterer
- Re: Combining a variable with a counter?
- References:
- Combining a variable with a counter?
- From: Christoph Hörterer
- Combining a variable with a counter?
- Prev by Date: Re: Combining a variable with a counter?
- Next by Date: Re: exec tcpdump and tethereal
- Previous by thread: Re: Combining a variable with a counter?
- Next by thread: Re: Combining a variable with a counter?
- Index(es):
Relevant Pages
|