MAXSTRLEN on unlimmited Text variables

It has probably been blogged or posted about, but I must have missed it.

While recording a How Do I video for the Address Integration Pattern I noticed that you cannot declare an address array without declaring the length.

Here is why:

If I declare an address array without specifying the length I get this error:

Arithmetic operation resulted in an overflow.

2014-12-02_21-41-47

Ambiguous…

And this is the code:

2014-12-02_21-42-17

Since MAXSTRLEN returns 2147483647, this function blows up.

Here is proof:

2014-12-02_21-47-47

The max value for integer (int32) is 2147483647. Adding 1, is not possible.

5 Comments

  1. Natalie says:

    The MAXSTRLEN issue was mentioned first (?) in Kamil’s comment of Vjeko’s post: http://vjeko.com/blog/unlimited-text-length-in-nav-2013 (however without mentioning the exact error message).
    Thanks for reminding me of this topic anyway 🙂

    Like

    1. Natalie says:

      That’s how I understood you – you wondered if and where it might have been posted earlier, and here it is 🙂

      Liked by 1 person

  2. Yes it’s easy to miss, in fact I just had the exact same error today. Don’t really understand why I didn’t get it before…

    Like

  3. Lee Wright says:

    Thanks for this. So is this not a bug in NAV 2015 as this is the standard code? And i assume we just take out the +1 part? Thanks

    Like

  4. Dhanushka says:

    Thank you very much

    Like

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.