Chunking, Array's and I've lost my mind...

Sarah Reichelt sarah.reichelt at gmail.com
Thu Dec 15 23:05:47 EST 2005


> I'm trying to iterate through the contents of a text field (of varied
> length), acting on each character. As my script below shows, I can get
> the first character with no problems and have got the "Do something
> with it" part working like it should. Just can't figure out how to do
> the same for each remaining character in the field.
>

The easiest & fastest method is to use the "repeat for each" loop,
which would go like this:

on mouseUp
  repeat for each char tCurrentLetter in field "Phrase"
  -- do something with it
  end repeat
end mouseUp

"repeat for each" works by setting the loop variable to the next
specified chunk each time through the loop. It is really fast and
while the syntax takes a bit of getting used to, it will pay off if
you can make yourself use it.

HTH,
Sarah
not even thinking about giggling :-)



More information about the use-livecode mailing list