process data in steps of 50 lines

Matthias Rebbe matthias_livecode at me.com
Tue Jun 7 17:21:44 EDT 2011


Hi Mark,

thanks for your suggestion. That works so far, but maybe i can speed it up with Mark Tallutos technique.

Regards,

Matthias

Am 07.06.2011 um 15:27 schrieb Mark Schonewille:

> Hi Matthias,
> 
> Since the data is already in memory, there is no reason to process it in steps of 50. Also, using repear with x =... is very slow. Use repear for each with a counter instead:
> 
> put 0 into myCounter
> repeat for each line myLine in DATA
>  add 1 to myCounter
>  // do something with myLine
>  if myCounter = 50 then
>    // do something special
>    put 0 into myCounter
>    wait 0 millisecs with messages
>  end if
> end repeat
> 
> You could do it this way if you want to show a progress bar for example. You could also leave the counter out of your script entirely.
> 
> --
> Best regards,
> 
> Mark Schonewille
> 
> Economy-x-Talk Consulting and Software Engineering
> Homepage: http://economy-x-talk.com
> Twitter: http://twitter.com/xtalkprogrammer
> KvK: 50277553
> 
> New: Download the Installer Maker Plugin 1.6 for LiveCode here http://qery.us/ce
> 
> On 7 jun 2011, at 15:05, Matthias Rebbe wrote:
> 
>> Hi,
>> 
>> i have a variable which contains data with unspecified number of lines. It can be 3 but it can also be 9000 or whatever.
>> 
>> I need to do some calculations with each line of that data, but want to do it in steps of e.g. 50 lines.
>> 
>> I thought i would do that with 2 repeat loops ( one within the other). 
>> 
>> Something like this
>> 
>> 
>> repeat with i = 1 to the number of lines of DATA step 50
>> 
>>     repeat with k = 0 to 49
>>          do what ever with line (i+k) of DATA
>>    end repeat
>> 
>> end repeat
>> 
>> 
>> I could access  each line then in the repeat loop with line (i+k), but how do i take care if the number of lines are not a multiple of 50?
>> 
>> Is my solution the right one or is there a better way?
>> 
>> Regards,
>> 
>> Matthias
> 
> 
> _______________________________________________
> 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