ForEach listName() Where condition - also ordering lists
Posted: Wed Apr 07, 2004 4:02 am
Would it be possible to add an optional WHERE condition or similar to ForEach?
Effectively the WHERE is treated as a following IF and there is an endif applied just before the next.
Hopefully this would add no extra code to the final executable (the user currently has to do some testing inside the loop, which would no longer be needed) - and might in fact make this slightly smaller or faster through compilation optimisations.
[ASIDE]
Ordered lists would also be nice - I order lists using a Binary Search but it can get slow on large lists, with several SelectElement(LinkedList(), Position) and associated tests and postion adjustments happening before the item is included in the list.
But an optional ordering/sorting ability, something like:
would be great! - and would surely be fast.
[/ASIDE]
Code: Select all
ForEach listname() WHERE listname()\fldname = "YES"
.. process
next
; translating internally to something like:
ForEach listname()
if listname()\fldname="YES"
.. process
endif
next
Hopefully this would add no extra code to the final executable (the user currently has to do some testing inside the loop, which would no longer be needed) - and might in fact make this slightly smaller or faster through compilation optimisations.
[ASIDE]
Ordered lists would also be nice - I order lists using a Binary Search but it can get slow on large lists, with several SelectElement(LinkedList(), Position) and associated tests and postion adjustments happening before the item is included in the list.
But an optional ordering/sorting ability, something like:
Code: Select all
NewList listname.listDef() [ ASCENDING | DESCENDING [ IGNORECASE ] ON fldName ]
[/ASIDE]