repeat for..

Ken Ray kray at sonsothunder.com
Fri Oct 31 23:40:23 EST 2003


> This appears to work, but only for the first  2408 lines:
> 
> function testLoop pData
>    put 0 into n
>    repeat for each line L in pData
>      add 1 to n
>      put item 1 of L + 100 into item 8 of line n of pData
>    end repeat
>    return pData
> end testLoop
> 
> All the lines of pData after line 2408 are unchanged.
> Is this a known limit, or am I doing something wrong?

What you're doing is trying to affect 'pData', which when used in a
"repeat for each" loop can't be changed without odd results (it's
documented that way, BTW). To get what you want, you need to copy pData
into something else that you change and then return, like:

function testLoop pData
   put 0 into n
   put pData into returnData
   repeat for each line L in pData
     add 1 to n
     put item 1 of L + 100 into item 8 of line n of returnData
   end repeat
   return returnData
end testLoop

HTH,

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/ 




More information about the Use-livecode mailing list