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

Glen Bojsza gbojsza at gmail.com
Tue Feb 21 04:08:39 CST 2012

```Then repeat for is King in Livecode!

thanks for everyone's feedback .

On Tue, Feb 21, 2012 at 2:52 AM, Kay C Lan <lan.kc.macmail at gmail.com> wrote:

> Glen,
>
> Look at my test results more closely:
>
> Finding the 1st item of the 1st line using direct reference = 3ms
> Finding the last item of the last line using direct reference = 440294ms
> Finding the -1 item of the 1st line using direct reference = 5ms
> Finding the -1 item of the -1 line using direct reference = 733095ms
> Finding the first child of the first key = 3ms
> Finding the last child of the last key = 3ms
> Finding 1st item of 1st line using repeat for each line = 0ms
> Finding last item of last line using repeat for each line = 454ms
>
> Using direct reference is always slower than repeat for each, ESPECIALLY if
> the data is toward the end.
>
> I would amend Geoff's script to this:
>
>  repeat for each line L in the keys of yourArray
>       if L > 20 then
>          put L & cr after R
>          if L > 60 then
>                exit repeat
>         end if
>      end if
>  end repeat
>
> Don't waste cyling through lines you don't have to.
>
> HTH
>
> On Tue, Feb 21, 2012 at 5:37 PM, Glen Bojsza <gbojsza at gmail.com> wrote:
>
> > I was thinking more along the lines (no pun intended) of
> >
> > - find line number of starting value (for example line 578 )
> >
> > - find line line number of ending value (for example 12125)
> >
> > put lines 578 to 12125 into results
> >
> > Can this be done verses looping through each line since we know the xs
> > column is sequentially in order?
> >
> >
> >
> > On Tue, Feb 21, 2012 at 1:54 AM, Geoff Canyon Rev <gcanyon+rev at gmail.com
> > >wrote:
> >
> > > Depends on how big the list is. Unless there's a faster method than the
> > one
> > > I used (or you're using slower hardware than I am), you should be okay
> up
> > > to about 100,000 rows using something lik
> > >   repeat for each line L in the keys of yourArray
> > >      if L > 20 and L < 60 then put L & cr after R
> > >   end repeat
> > > -- 20 and 60 are your filter values,
> > > -- R is your result set
> > >
> > >
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> > subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
> >
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
```