IF STRLEN(t) + STRLEN(Format) + 2 <= 250 THEN t := t + ', ' + Format ELSE t := t +'...';sometimes this code would cause Text overflow on line t := t + '...'
IF STRLEN(t) + STRLEN(Format) + 5 <= MAXSTRLEN(t) THEN t := t + ', ' + Format ELSE t := t +'...';
Comments
http://www.codinghorror.com/blog/2010/0 ... ammer.html
For those who don't see it right away, there are a couple of problems with this. One, it hard codes the number 5, essentially chopping off characters from the result string. Two, if the string reaches the point where '...' is added, and the function is called again it will error out.
Here's some sample code to test for yourself:
t is a Text of length 10
toAdd is a Text of length 1
Where the code would ideally stop adding to the string it just continues. Something like this might have been more appropriate:
There are test cases like whether or not the concatenation of the strings matches the exact maximum length or if it matches the maximum length and there are still more elements (in which case a ... should be displayed instead of the element because there wouldn't be room for the ... after the element is added).
*sigh* I'm such a nerd :shock:
My Blog - nav.education
If it was a bug when V3 was still under support, then no partner reported it as a bug. Or they just fixed the problem in version v3.1, 3.6, or later.
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
My Blog - nav.education
You're right... I didn't read the whole post... :oops:
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Wouldn't surprise me at all. This one probably doesn't occur too often and even looking at the code is easy to overlook.
My Blog - nav.education
The system is just not designed for
STRLEN(t) + STRLEN(Format) + 2 > 250 in 3.0 and
STRLEN(t) + STRLEN(Format) + 5 > MAXSTRLEN(t) in 5.0
Sometimes when you're allowed to do something it doesn't really mean it should be done.
Remember that Nav is belonged to the previous era
ERP Consultant (not just Navision) & Navision challenger
How can you call an overflow error that could easily be coded for not a bug?
But that's exactly what they were trying to design for. They wanted to put a "..." at the end of the string when it couldn't fit anymore characters. They obviously expected to get large strings at some point.
My Blog - nav.education