Using 'for each' to modify a container
wjm at wjm.org
Wed Oct 11 09:34:47 EDT 2006
You shouldn't try to change the tires while the car is moving, and you
shouldn't try to modify the entity being used as the basis of a repeat loop.
For example, if you were to say
repeat with i = 1 to 20
you shouldn't try to modify i within the loop.
If you say
repeat for each line theLine in myVariable
you shouldn't try to modify myVariable within the loop.
There are probably many possibilities for your solution, but I would
probably do it this way:
put empty into newContainer
repeat for each line thisLine in vContainer
put doSomeFunction(item -2 of thisLine) into item -2 of thisLine
put thisLine & return after newContainer
put char 1 to -2 of newContainer into vContainer
Mark Powell wrote:
> I want to use the 'for each' form of the repeat loop, but don't know how
> to use it to modify data within a container. For example:
> repeat for each line thisLine in vContainer
> put doSomeFunction(item -2 of thisLine) into item -2 of thisLine
> --how do I get the change back into vContainer?
> end repeat
More information about the Use-livecode