goofy question about "repeat for each"

Jerry Jensen jerry at jhjensen.com
Mon Mar 25 18:57:59 EDT 2019


Hi jbv,
What version of LC are you using? Here’s a quote from the LC 8.1.10 dictionary:
“Starting in version 7.0 it is possible to modify the container variable inside a for each loop without affecting the iterations of the loop.”
Could this be biting you?
.Jerry

> On Mar 25, 2019, at 2:44 PM, jbv via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> Hi again,
> 
> I finally solved the problem by modifying the loop
> as follows :
>    repeat for each line j in cc
>      get item 1 of j
>      add 1 to it
>      put return & it & "," & item 2 of j after var2
>    end repeat
> 
> But I still don't understand why the previous version
> led to unexpected values...
> 
> Le 2019-03-25 15:31, jbv via use-livecode a écrit :
>> Hi list,
>> I have a list of values such as :
>>  540,20
>>  542,22...
>> one per line in a variable named cc.
>> Now I'm running the following loop :
>>   repeat for each line j in cc
>>     add 1 to item 1 of j
>>     put return & j after var2
>>   end repeat
>> goofy question : does each iteration of the loop
>> change the values of each line of cc, or does it
>> only change the value of j ?
>> I'm asking because it seems that I am facing some
>> weird and unexpected modifications in the variable
>> with a huge number of lines...
>> Thanks in advance.
>> jbv






More information about the use-livecode mailing list