Repeat syntax addition

Jerry Jensen jhj at jhj.com
Sun Apr 5 18:19:55 EDT 2015


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






More information about the use-livecode mailing list