Looping
David Burgun
dburgun at dsl.pipex.com
Tue Apr 18 10:48:59 EDT 2006
Hi,
In general, you just create a number of loops! Like so:
repeat with myLineCount = 1 to the number of lines in myList
--
-- LineCount will now be set to 1, 2, 3, etc. until the end of the
list is reached, so
--
put line myLineCount of myList into myLineText
--
-- Will put the text of the line specified by myLineCount into
myLineText, if you now wanted to loop thru each
-- of the characters in myLineText, you would just do this:
--
repeat with myCharCount = 1 to the number of chars in myLineText
put char myCharCount of myLineText into myChar
if myChar = "A" then
beep
end if
end repeat
end repeat
You can do this with items, lines, characters etc, you just specify
the type of container you are accessing (e.g. line, item, word, char,
etc.).
You can also use this form of repeat
repeat with each line myLineText in myList
-- This just sets myLineText to each line in myList starting at the
beginning.
end repeat
Hope this Helps
All the Best
Dave
More information about the use-livecode
mailing list