repeat with each
Klaus major-k
klaus at major-k.de
Mon Sep 22 09:11:21 EDT 2014
Hi Larry,
Am 22.09.2014 um 15:04 schrieb larry at significantplanet.org:
> Hello,
>
> I have never been able to understand how to use the each form in a repeat statement.
>
> Can anyone explain why this code does not work? It is almost verbatim from the example in the LC dictionary.
>
> on mouseUp
> repeat for each word thisWord in field justOne
> put "," after thisWord
> end repeat
> sort items of field justOne
> end mouseUp
>
> It does not insert the commas. Supposedly the each form is a lot faster than using
>
> "put x + 1 into x"
> "put "," after word x of field justOne
"repeat for each XXXX..." is READ-ONLY!
Means you cannot modify thisWord here!
Collect your data in a variable first, then write stuff back to field:
...
## Never forget to put QUOTES around object names!
repeat for each word thisWord in field "justOne"
put thisWord & "," after tNewVariable
end repeat
delete char -1 of tNewVariable
sort item of tNewVariable
put tNewVariable into fld "justOne"
...
> Thanks,
> Larry
Best
Klaus
--
Klaus Major
http://www.major-k.de
klaus at major-k.de
More information about the use-livecode
mailing list