Selected Line Only

Rob Mostyn mostyn at platformis.net
Mon Jul 11 10:45:42 UTC 2022


We have done some benchmarking on this and the simple conclusion is this:

If you have nothing happening in the loop then the CPU used to process $Loop() is more expensive than using For loop.

But I have never written a loop that does nothing inside it, so this is a rather silly indicator of performance.

As soon as you put work inside the loop then its the work being done that determines the CPU used and the overhead of $Loop() is negligible.  Really... next to nothing!  The difference processing 500,000 records would be something like 500 seconds compared to less than 501 seconds.  Your users will not notice it.

Advantages for me:
a.	The code is much easier to read.
b.	There are fewer keystrokes to define the loop.
c.	Looping through selected lines only is very easy with fewer keystrokes still

Rob

> On 11 Jul 2022, at 11:18, Martin Obongita via omnisdev-en <omnisdev-en at lists.omnis-dev.com> wrote:
> 
> Hi Rob,
> Won't the while$loop be slower than a FOR loop, assuming you have 500,000 transactions?
> Martin.
>    On Monday, July 11, 2022 at 11:46:36 AM GMT+3, Rob Mostyn <mostyn at platformis.net> wrote:
> 
> And here is another take on this issue:
> 
> We have a method/function in our startup_task (and copied into the superclass for remote_tasks) called $Loop.
> 
> When running our code you will frequently see this:
> Calculate ilDisplay.$line as 0
> While $Loop(ilDisplay)
>     # do whatever
> End while
> 
> for selected lines only it would look like this:
> When running our code you will frequently see this:
> Calculate ilDisplay.$line as 0
> While $Loop(ilDisplay,kTrue)
>     # do whatever
> End while
> 
> 
> 
> Here is the contents of $Loop:
> param1:  pList (field reference)
> param2: pSelectedOnly (boolean, default kFalse)
> 
> If pList.$line=0
> Do pList.$first(pSelectedOnly)
> Else
> Do pList.$next(pList.[pList.$line],pSelectedOnly)
> End If
> Quit method pList.$line
> 
> 
> Regards,
> Rob
> 
> 
>> On 11 Jul 2022, at 06:45, Rudolf Bargholz <rudolf at bargholz.ch> wrote:
>> 
>> Hi Martin,
>> 
>> Calculate lLineCount as List.$linecount
>> For List.$line from 1 to lLinecount step 1
>>   If List.0.$selected
>>     ... Do stuff on the selected lines
>>   End If
>> Enf For
>> 
>> If you are in an object class, in an instance, then the following can also work:
>> 
>> Do List.$sendall($cinst.$processLine($sendallref),$ref.$selected)
>> 
>> For each selected line the method $processLine is called with the List as a field reference parameter with the appropriate selected line set as current.
>> 
>> Regards
>> 
>> Rudolf Bargholz
>> 
>> -----Ursprüngliche Nachricht-----
>> Von: omnisdev-en <omnisdev-en-bounces at lists.omnis-dev.com> Im Auftrag von Martin Obongita via omnisdev-en
>> Gesendet: Sonntag, 10. Juli 2022 22:21
>> An: omnisdev-en at lists.omnis-dev.com
>> Cc: Martin Obongita <martin.obongita at yahoo.com>
>> Betreff: Selected Line Only
>> 
>> Hi Friends, What is the syntax for "Selected lines only" in the FOR loop statement, For each line in list from 1 to iDataList step 1?
>> 
>> _____________________________________________________________
>> Manage your list subscriptions at https://lists.omnis-dev.com Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
>> _____________________________________________________________
>> Manage your list subscriptions at https://lists.omnis-dev.com
>> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
> 
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
> 
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com



More information about the omnisdev-en mailing list