Err:Reduce the Expression so it is less complex in for-loops
rthsw
Member Posts: 73
Hi there, there is clearly a error in nesting Loop-statements in Navision.
Try this (tested in Navision 4.0 SP3, build 27010):
Define a till e as integer or decimals (no difference), put the code in a Codeunit-run, in a tablefield, in a tablefunction, in a codeunit-Function... whereever you want.
Try to compile, you get the error mentioned in the headline. =D>
Both functions (test := ...) will lead to the error, much more (i.e. format(padstr) will also.
You can use this short Var-names, or even longer Var's, no difference. [-(
it seems, as the Compiler will turn into a stack-error. :bug:
If you comment the test :=... or remove one For-loop, everything will work fine, if you move 1-4 loops into an sub-codeunit, everything will work fine.
If you add another Loop, the error stays, if you delete the begin/end, where possible, the error stays. ](*,)
Did someone had this error before, and found a solution which will not need to call a sub-codeunit? :?:
Try this (tested in Navision 4.0 SP3, build 27010):
for a := 1 to 2 do begin
for b := 1 to 2 do begin
for c := 1 to 2 do begin
for d := 1 to 2 do begin
for e := 1 to 2 do begin
test := padstr('',5,'.');
test := copystr('Test',1,2);
end;
end;
end;
end;
end;
Define a till e as integer or decimals (no difference), put the code in a Codeunit-run, in a tablefield, in a tablefunction, in a codeunit-Function... whereever you want.
Try to compile, you get the error mentioned in the headline. =D>
Both functions (test := ...) will lead to the error, much more (i.e. format(padstr) will also.
You can use this short Var-names, or even longer Var's, no difference. [-(
it seems, as the Compiler will turn into a stack-error. :bug:
If you comment the test :=... or remove one For-loop, everything will work fine, if you move 1-4 loops into an sub-codeunit, everything will work fine.
If you add another Loop, the error stays, if you delete the begin/end, where possible, the error stays. ](*,)
Did someone had this error before, and found a solution which will not need to call a sub-codeunit? :?:
0
Comments
-
I never needed more than 2 nested fors.... ;-) if you need this, the error is somewhere else for me... 8)0
-
Is this actually something you programmed for a customer? I would love to know what that is for. I agree with Kamil that if that is an error then fix your code that it compiles. The mere fact that you get a compilation error doesn't mean it's a bug. You might just have discovered a system limitation.0
-
Hi,
You not using a - e variables why not use one loop with 1 to 32 ?
You could use a loop on the integer table if you need so may loops.0 -
Move some loops (or code inside loops) into function (no need for other codeunit) and problem will be solved.
I will agree with all comments. I have no idea why you need this? Can you give some example?0 -
Replace all "for" with REPEAT..UNTIL & it will work.
C/Side is a primitive language. "for" is probably considered too advanced for it to handle after a certain number of loops, my guess is the memory allocation is not optimized or the exe itself is never optimized even after it moved to 32 bit environments.NAV - Norton Anti Virus
ERP Consultant (not just Navision) & Navision challenger0
Categories
- All Categories
- 75 General
- 75 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

