repeat for each....
Dave Cragg
dcragg at lacscentre.co.uk
Mon Aug 25 08:17:01 EDT 2003
At 1:45 pm +0100 25/8/03, Mark Smith wrote:
>This is driving me barmy...can any kind soul here explain why this works:
>
>on tryLoopWith
> put "a,b,c,d,e,f" into charList
> repeat with n = 1 to the number of items in charList
> put item n of charList into line n of newCharList
> end repeat
> put newCharList && "with"
>end tryLoopWith
>
>but this throws up a 'bad chunk expression" :
>
>on tryLoopFor
> put "a,b,c,d,e,f" into charList
> repeat for each item n in charList
> put item n of charList into line n of newCharList
> end repeat
> put newCharList && "for"
>end tryLoopFor
In your second example, the variable n doesn't contain a number but
the actual value of the current item in the list.
Try this:
on tryLoopFor
put "a,b,c,d,e,f" into charList
repeat for each item n in charList
put n & return after newCharList
end repeat
delete char -1 of newCharList ## delete final return
put newCharList && "for"
end tryLoopFor
Dave
More information about the use-livecode
mailing list