repeat for..
Dar Scott
dsc at swcp.com
Fri Oct 31 18:34:27 EST 2003
On Friday, October 31, 2003, at 03:42 PM, Mark Smith wrote:
> 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
I don't think you should be modifying pData while it is used in a
repeat like this. An immediate step would be to make a copy of that.
That would still have the problem of random line access, though.
However, I think something like this would be better (untested, off the
top of my head, etc.):
function testLoop pData
put empty into resultLines
repeat for each line L in pData -- fast
put L into resultLine
put (item 1 of L) + 100 into item 8 of resultLine
put resultLine & LF after resultLines -- fast
end repeat
return char 1 to -1 of resultLines -- remove last LF
end testLoop
Dar Scott
More information about the use-livecode
mailing list