Selected Line Only
Doug Easterbrook
doug at artsman.com
Mon Jul 11 14:34:22 UTC 2022
hi Martin.
people have touched on various ways to process selected lines in a list. Thise is stuff I’ve found to be useful in my past
option 1: For each line in list
advantages ..
1) tends to be faster than processing selected lines using option 2 (at least in historical benchmarks, I haven’t redone benchmarks in a few years to see if the notation version has improved in performance
2) uses a reversible block to restore the current list and line number when finished
disadvantage.
1 loops within loops processing multiple lists .. not so easy
begin reversible block
set current list as myList
calcilate myList.$line as myList.$line
end reversible block
For each line in list (Selected lines only) from 1 to myList.$linecount step 1
end for
option 2. using notation, looping to only look at selected lines
Major advantage:
you can do loops within loops processing lists
you can process selected lines
you can process selected lines in reverse order
you can add a filter that must match lines in order to be processed.
ie: the ktrue parameter in $first and $next . says selected lines only. very useful to make it go faster
there are other parameers in the $first and $next to process the loop backwards and add filters
calculate orginalLine as mylist.$line
do myList.$first(ktrue) returns booleanFlag
while booleanFlag
do myList.$next(0,ktrue) returns booleanFlag
end while
calculate mylist.$line as orginalLine
Option 3: where you only care about the selected lines and want to do a bunch of work with them, never putting anything back into them
calculate templist as myList
do templlist.$remove(klistkeepselected)
for templist.$line from 1 to templist.$linecount
end for
or the notation version — which, I confess, I don’t use often — I prefer the above ‘for’ construct
calculate templist as myList
do templlist.$remove(klistkeepselected)
do templlist.$first() returns booleanFlag
while booleanFlag
do templlist.$next() returns booleanFlag
end while
These days, when I process selected lines in a list, expecially in table classes and for code safety, I use the $first(ktrue) and $nect(0,ktrue) approach
do myList.$first(ktrue) returns booleanFlag
while booleanFlag
do myList.$next(0,ktrue) returns booleanFlag
end while
hope that helps.
Doug Easterbrook
Arts Management Systems Ltd.
mailto:doug at artsman.com
http://www.artsman.com
Phone (403) 650-1978
> On Jul 10, 2022, at 1:20 PM, Martin Obongita via omnisdev-en <omnisdev-en at lists.omnis-dev.com> wrote:
>
> 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
More information about the omnisdev-en
mailing list