Stopping a Repeat Until Loop
sabzam
Member Posts: 1,149
Dear All,
I have got a repeat until loop and I need to stop a particular cycle and go to the next loop in certain conditions. The only method which I've found out so far is to use the begin...end within the repeat until but I'm looking for a cleaner way. Does anyone know of an alternative?
Regards,
Steve
I have got a repeat until loop and I need to stop a particular cycle and go to the next loop in certain conditions. The only method which I've found out so far is to use the begin...end within the repeat until but I'm looking for a cleaner way. Does anyone know of an alternative?
Regards,
Steve
0
Comments
-
It depends on what you need to achieve.
You can do something like
REPEAT
UNTIL ((NEXT = 0) OR (MyBoolean = FALSE))
But keep in mind that the last NEXT will be called before exiting and the pointer will move to the next record.
What exactly do you want to do?0 -
Try this....
Rec.findset then repeat if condition = true then Loopexit := true; until (Rec.Next=0) or (Loopexit = true);0 -
The issue is that I do not want to go through the whole cycle. I can set as loopexit = true or something of the sort but I was looking for a function similar to break which would go to the next loop.0
-
Put that section of code in its own function. Then you can place the EXIT where you want.There are no bugs - only undocumented features.0
-
Ok thanks to everyone0
-
vijay_g wrote:
if condition = true then
](*,) ](*,) ](*,) ](*,) ](*,) ](*,) ](*,) ](*,)David Singleton0 -
David Singleton wrote:vijay_g wrote:
if condition = true then
](*,) ](*,) ](*,) ](*,) ](*,) ](*,) ](*,) ](*,)
Are you expection
???if condition then0 -
-
Or you can do this:
until (Rec.Next=0) or (condition);
Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book0 -
sabzam wrote:Dear All,
I have got a repeat until loop and I need to stop a particular cycle and go to the next loop in certain conditions. The only method which I've found out so far is to use the begin...end within the repeat until but I'm looking for a cleaner way. Does anyone know of an alternative?
Regards,
Steve
If I understand you correctly, you are looking to break out of a particular cycle thru the Repeat..Until loop but continue the loop with the next value. Not break entirely out of the loop.Rec.findset then repeat LoopFunction; until (Rec.Next=0);Function LoopFunction // [place code here to process each loop cycle. You can then exit this fucntion where desired and the Repeat..Until will continue with the next record.There are no bugs - only undocumented features.0 -
Never mind... I see now. :oops:David Singleton0
-
Yes, and they all terminate the loop. But I don't think that is what he is trying to do. I think he is trying to abort a single run thru the loop (based on some condition) but continue with the next record.
But then I could be wrong... :-$There are no bugs - only undocumented features.0 -
Hi,
do u want a code like breaking the whole loop or like skip the particular record in that loop?0 -
You can use Exit, when a particular condition is met, for example
REPEAT
<SOME CODE HERE>
IF Condition THEN
EXIT;
<SOME CODE HERE>
UNTIL rec.NEXT=0;0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 329 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

