Continue to end of loop

Fommo
Member Posts: 138
Hi there
Is there some nice way to accomplish the following:
That is some kind of "goto end of loop" or "continue to next turn" functionality. IF I would use IF - ELSE IF - ELSE IF it would be such a nasty tree of ugly indentations and after a while it will BEEP as the lines can't go over the right margin.
Is there some nice way to accomplish the following:
WHILE (some condition) THEN BEGIN statement1 IF NOT (statement1 = success) THEN Continue to next turn in the loop statement2 IF NOT (statement2 = success) THEN Continue to next turn in the loop ... And so on ... END;
That is some kind of "goto end of loop" or "continue to next turn" functionality. IF I would use IF - ELSE IF - ELSE IF it would be such a nasty tree of ugly indentations and after a while it will BEEP as the lines can't go over the right margin.
0
Comments
-
A case-Construct?
while SomeCondition case true of Condition1: begin .. end; Condition2: begin .. end; . . . else begin .. end; end;
Is that what you´re looking for?0 -
WHILE (some condition) DO BEGIN blnContinueWithStatements := Statement1(); IF blnContinueWithStatements then blnContinueWithStatements := Statement2(); IF blnContinueWithStatements then blnContinueWithStatements := Statement3(); ... END;
Remark:
Each statement must return a boolean.
TRUE : if the code must continue with the statements
FALSE: if the code must skip the next statements and continue with the loop.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
kriki wrote:
WHILE (some condition) DO BEGIN blnContinueWithStatements := Statement1(); IF blnContinueWithStatements then blnContinueWithStatements := Statement2(); IF blnContinueWithStatements then blnContinueWithStatements := Statement3(); ... END;
Remark:
Each statement must return a boolean.
TRUE : if the code must continue with the statements
FALSE: if the code must skip the next statements and continue with the loop.
Quite a good idea, actually. Thanks a lot Kriki! =D>0 -
[Topic moved from 'NAV/Navision' forum to 'NAV Tips & Tricks' forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
WHILE SomeCondition DO BEGIN CASE TRUE OF Statement1:; Statement2:; Statement3:; Statement4:; Statement5:; END; END;
All "Statement#"-function must return a Boolean.
In each round, they are called from top to bottom until someone returns TRUE, then the CASE-statment is "solved" and the rest of the "Statements" are ignored.
This one is probably the shortest, althou maybe not the easiest to understand for a beginner.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 320 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