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

Geoff Canyon Rev gcanyon+rev at gmail.com
Tue Feb 21 02:12:30 EST 2012


You can get away with straight text for small data sets, but I would never
suggest using a single variable and line references for random access on
anything more than a few tens of thousands of lines -- although I will
point out that in your test, even working with a million lines meant a
worst case scenario of <1/10th of a second.

But that isn't what "repeat for each" is about. It's for doing something
with all the data, either sequentially or in aggregate.

If you need random access to a large data set, then an array or a database
is clearly the way to go.

On Mon, Feb 20, 2012 at 11:37 PM, Kay C Lan <lan.kc.macmail at gmail.com>wrote:

> Excellent rules of thumb, though there is a caveat to all this.
>
> Unfortunately I haven't seen a further response from Glen, as I was going
> to wait to ask one more question, before offering further suggestions; but
> I'll now offer it anyway.
>
> Glen doesn't mention what the final use/access of the data will be. If you
> are only every going to deal with the data as a whole, then repeat for each
> line will generally be the fastest. On the other hand, if after preparing
> all your lists and merging them, the final purpose is to pick small bits
> and pieces out of it from here, there and anywhere, arrays (or a db) might
> be better.
>
> So the caveat is, always test and compare. It might be faster to create and
> merge the data using repeat for each, but slower to access it that way. It
> might be slower to merge the data using arrays, but faster to access it
> final format.
>



More information about the use-livecode mailing list