Continue Equiv. in C Side

wolfulium
Member Posts: 30
So I am wanting this:
I know there is a CurrReport.SKIP, however I am trying to achieve this using a CodeUnit
Thanks
Loop through list { if TODAY-item.LastRunDate < 30 { continue; } // code that adds lastrundate to item }
I know there is a CurrReport.SKIP, however I am trying to achieve this using a CodeUnit
Thanks
0
Best Answer
-
I figured the use of the work continue was self explanatory enough. I want to skip an item in a loop.
Like the key word continue does in most of the languages. But apparently this language does not have it.
So what I ended up doing was adding a global variable and used that.REPEAT continue := false; IF (date <> 0D) THEN IF TODAY - date < 5 THEN continue := true; IF NOT continue THEN BEGIN // code i wanted to run if the date was older than 5 days END;
0
Answers
-
Hi,
What exactly do you want to achieve? Loop through the Item table and do what? And stop when?
SlawekSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
Hi, as Slawek wrote, you have to provide more info - so just guess ...
A condition should do the same:FOREACH dotnetElement IN dotnetElements DO BEGIN IF (TODAY - dotnetElement.LastRun) >= 30 THEN BEGIN // handling code ... END ELSE IF counter > 12345 THEN BREAK; // break the loop if too many elements // else do nothing => continue END;
Regards
xStepa0 -
I figured the use of the work continue was self explanatory enough. I want to skip an item in a loop.
Like the key word continue does in most of the languages. But apparently this language does not have it.
So what I ended up doing was adding a global variable and used that.REPEAT continue := false; IF (date <> 0D) THEN IF TODAY - date < 5 THEN continue := true; IF NOT continue THEN BEGIN // code i wanted to run if the date was older than 5 days END;
0 -
Hi,
1) REPEAT alway goes with UNTILREPEAT UNTIL boolean
2) UNTIL takes a boolean variable or expression, and stops the loop when the variable or expression evaluates to TRUE;
3) you can use filters to limit the number of records you're looping through, instead of looping through all and running a code doing some manipulation in few cases.
Instead of having the following code inside the loopIF (date <> 0D) THEN IF TODAY - date < 5 THEN continue := true;
you can build an equivalent loop with a filter. Assuming that you are looping through a record variable called Item, and the record has date field::Item.SETFILTER(date, '<%1', TODAY - 5); IF Item.FINDSET THEN REPEAT //whatever is inside this loop it will be only executed //for Item records having the "date" field more than 5 days old UNTIL Item.Next = 0;
SlawekSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030
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