Repeat syntax addition

Peter Haworth pete at lcsql.com
Tue Apr 7 13:33:32 EDT 2015


I'm really liking this feature.  I just used it in a series of nested
repeat statements that traverse their way through an array with 5 levels of
keys by writing a function for each level of key.  Makes the code so much
more readable.

Pete
lcSQL Software <http://www.lcsql.com>
Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>

On Sun, Apr 5, 2015 at 8:21 PM, Mike Bonner <bonnmike at gmail.com> wrote:

> Use of the word "Container" is a bit deceptive.  Perhaps "datasource" would
> be better.  Is it still possible to add notes to the dictionary?
>
> On Sun, Apr 5, 2015 at 5:11 PM, Peter Haworth <pete at lcsql.com> wrote:
>
> > I'd guess the last of the options.
> >
> > The more I think about this, the more I think there should be mention of
> > this in the dictionary entry for repeat.
> >
> > It's a little like the ability to use a function to create a sortkey in
> the
> > sort command.  Nothing in the dictionary about that except for a user
> note.
> >
> > Pete
> > lcSQL Software <http://www.lcsql.com>
> > Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
> > SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>
> >
> > On Sun, Apr 5, 2015 at 3:40 PM, Mike Bonner <bonnmike at gmail.com> wrote:
> >
> > > Yeah, kinda makes sense that it would work that way. Grab the data from
> > the
> > > container once, do magic things behind the scenes to get it ready to
> go,
> > > then loop through the lines.  I guess it could work either way though,
> > > where it uses byte offsets to get the next chunk, which would have made
> > the
> > > function method really suck for large data sets.
> > >
> > > Now I'm curious.. what exactly does repeat for each do?  Split on cr,
> > sort
> > > the keys and increment each loop to pop out the right line from the
> > array?
> > > Store all the data in a temp variable and read each line (item, char)
> by
> > > start/end position?
> > >
> > > On Sun, Apr 5, 2015 at 4:19 PM, Jerry Jensen <jhj at jhj.com> wrote:
> > >
> > > > Hi Mike,
> > > >
> > > > > On Apr 5, 2015, at 12:31 PM, Mike Bonner <bonnmike at gmail.com>
> wrote:
> > > > >
> > > > > While not exactly whats been requested, this works pretty well:
> > > > >
> > > > >    repeat for each line tLine in (myFilter(sData,"abc*","with"))
> > > > >
> > > > > I like the way a where clause reads as in the OP, but being able to
> > use
> > > > an
> > > > > inline function for data generation is rather powerful, and if all
> > you
> > > > need
> > > > > is a filter, setting up a function to do so is pretty straight
> > forward.
> > > >
> > > > Good trick! I didn't know you could do that either.
> > > >
> > > > I wondered if the function was called just once, or on every repeat.
> > Your
> > > > exapmle wouldn't tell, because the function would return the same
> stuff
> > > > every time.
> > > >
> > > > So I tested it. The answer is that the function is called only once.
> > > Good!
> > > >
> > > > global gCount
> > > >
> > > > on mouseUp
> > > >    global gCount
> > > >    put 0 into gCount
> > > >    repeat for each line L in mylines()
> > > >       put L & cr after msg
> > > >    end repeat
> > > >    put gCount after msg -- how many times mulines() was called
> > > > end mouseUp"
> > > >
> > > > function mylines
> > > >    global gCount
> > > >    add 1 to gCount
> > > >    return "1" & cr & "2" & cr & "3" & cr
> > > > end mylines
> > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > 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
> > >
> > _______________________________________________
> > 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
>



More information about the use-livecode mailing list