Text interpreted as Integer in GET

rocatisrocatis Posts: 159Member
I just found this out by chance, and I cannot decide whether it is clever or idiotic:

Int is a record of type Integer:

Int.GET('3') will actually get Int.Number = 3...

This is in NAV 2018. I have not investigated other versions, but I am pretty sure this has not always worked that way.
Brian Rocatis
Senior NAV Developer
Elbek & Vejrup


  • Wisa123Wisa123 Posts: 243Member

    Im tending towards idiotic.
    I tried what you showed, it also works in 2013 - without any problems.

    Then i got curious why and how it worked and looked into the c# resulting from the snippet.
    maps to
    @int.Target.ALGetSafe(DataError.ThrowError, 449479, ALCompiler.ToNavValue(@"55"));

    while the normal int-based way results in
    maps to
    @int.Target.ALGetSafe(DataError.ThrowError, 449479, ALCompiler.ToNavValue(12));

    So the ALCompiler actually does the cast to int for us internally.
    Weird, but ok. Im still going for idiotic, dont use this in any way.


Sign In or Register to comment.