 |
user0101 Apprentice
Joined: 01 Aug 2003 Posts: 100 Location: USA
|
Posted: Sat Apr 03, 2004 2:09 am
Variable Problems |
I am playing with some code for a script, so this is all hypothetical for now. Larkin, I got inspiration from some of your code snippets, so I'm primarily looking at you here.
#VAR testv {(blah1|blah11)|(blah2|blah22)}
How do you change the contents of @testv.1.2, or anything else for that matter? |
|
|
 |
Carabas GURU

Joined: 28 Sep 2000 Posts: 434 Location: USA
|
Posted: Sat Apr 03, 2004 4:51 am |
Possibly the ugliest way (and the only way I can think of) is like this:
%replaceitem(%replaceitem("blah12",2,%item(@testv,1)),1,@testv)
You can of course make your own function for this.
#FUNCTION replacenesteditem {%replaceitem(%replaceitem("%1",%3,%item("%4",%2)),%2,"%4")}
Syntax: @replacenesteditem(string,n,i,list)
Where n is item to manipulate, and i is the nested item to replace.
Still kind of ugly, but is certainly easier. This will now accomplish the same thing.
@replacenesteditem("blah12",1,2,@testv) |
|
|
 |
user0101 Apprentice
Joined: 01 Aug 2003 Posts: 100 Location: USA
|
Posted: Sat Apr 03, 2004 5:54 am |
That works, and I have another question. What function can be used to return the index of the loop, but not the contents that the index is pointing to? Such as, %pointer() or something that would return a 1 if its on loop one of execution.
|
|
|
 |
nexela Wizard

Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: Sat Apr 03, 2004 11:08 am |
I don't know of a function right off hand but in your loop you can do this
loopcount=%i
and just refrencing @loopcount will till you where in the loop you are at |
|
|
 |
Kjata GURU

Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Sat Apr 03, 2004 4:13 pm |
%i may also be used by itself without first assigning it to a variable. Do know that %i behaves differently depending on what loop you are running. For #LOOP, %i is the current iteration index, while for #FORALL it is the item of the stringlist for the current iteration.
|
|
|
 |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|