How to use an array to solve the following...

gcanyon+rev gcanyon+rev at gmail.com
Mon Feb 20 13:34:27 EST 2012


On Feb 19, 2012, at 10:42 PM, dunbarx at aol.com wrote:

> Kay's is much faster than mine.

Don't worry about it, it happens to just about every person who's had experience with HyperCard when they come over to LiveCode: the "repeat for each" aha! moment: any time you find yourself writing:

repeat with i = 1 to the number of lines|words|items of someContainer

stop. Rewrite it as:

repeat for each line|word|item in someContainer

With the other way, every time in the repeat that you use "chunk i of someContainer" you're forcing the engine to count through all the chunks up to that one. With "repeat for each" you're not. 

If you need to know which chunk you're on, use an index variable. 



More information about the use-livecode mailing list