Re: Combining a variable with a counter?



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?
.



Relevant Pages

  • lk-changelog.pl 0.325
    ... This script is used by Linus and Marcelo to rearrange and reformat BK ... +'christoph:lameter.com' => 'Christoph Lameter', ... 'hawkes:oss.sgi.com' => 'John Hawkes', ... 'lethal:unusual.internal.linux-sh.org' => 'Paul Mundt', ...
    (Linux-Kernel)
  • Re: Arghhhh on the Biden/Palin debate!
    ... To Shurley....how do you get from my comment that I hate smart, ... Palin were just polictical slurrs. ... creating a script or dialogue that will sway an audience, ... successful in other areas but not here. ...
    (alt.gathering.rainbow)
  • Re: winsock??
    ... As Christoph said, ... script. ... why would you be trying to use winsock from ... >> Both expect two strings. ...
    (microsoft.public.scripting.vbscript)
  • Re: Using yes no dialog to install software, need to return an err
    ... I am trying to figure out how to return a none successful error ... >> return a non successful error code to SMS it would make the reporting and ... When i run this script according to SMS it ran ... A successful installation will always return ...
    (microsoft.public.scripting.vbscript)
  • Issue running ldf script
    ... script and the logs indicate that it has been successful in modify the ... when I use ADSI edit to view these attributes under the ...
    (microsoft.public.exchange.admin)