I am having problems stepping backwards through a table using the Repeat Until Loop. The logic is simple .... go to the bottom of the table then step backward by one record. Attached is a simple example.
IF Customer.FIND('+') THEN
REPEAT
"Do Function"
UNTIL Customer.NEXT <0 ;
When executed, the record remains at the last record.
Even if I add an explicit step -1 ...
"Customer.NEXT(-1)"
after the "Do Function" the record pointer advances by one when the Until command is reached.
I must be missing something?
A
s outline in the HELP...
Steps
Data type: integer
Used to define the direction of the search and how many records to step over. This value... Tells the system to...
> 0 Search Steps records forwards in the table.< 0 Search Steps records backwards in the table.= 0 No effect
If you do not specify Steps, the system finds the next record.
Comments
your next statement should read as follows
Hope this helps
Albert
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
We plan on migrating to MS SQL within the year. What kind of loop procedure would you use under SQL to avoid this performance issue?
Mike
Set it to Descending and loop through the normal way...
[edited]Found it! (Not sure why kine didn't include this in his statement up above...)
Thanks for your reply. I will remember this when we migrate to SQL.
Mike
Exactly, and it have much better performance for sets of records which have few records (less than 500). And it is why I have not included the "second" part about the descending sort order... ;-)
Better is to remember rule "do not use descending order and backward loop" if possible.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.