Code/Text Caveat

rocatisrocatis Member Posts: 163
I don't like this:
OBJECT Report 88888 Code/Text Inconsistency
{
  PROPERTIES
  {
    ProcessingOnly=Yes;
    OnPreReport=BEGIN
                  X := 'ABC';
                  Y := 'ABC';

                  X := X + 'D';
                  X += 'E';

                  Y := Y + 'D';
                  Y += 'E';

                  MESSAGE('X=%1, Y=%2',X,Y);
                END;

  }
  CODE
  {
    VAR
      X@1000000000 : Text[30];
      Y@1000000001 : Code[10];

    BEGIN
    END.
  }
}
Of course we're dealing with different Data Types but Text and Code share a lot of functions where they are interpreted in the same way. Except, apparently, when using += in assignments...
Brian Rocatis
Senior NAV Developer
Elbek & Vejrup

Comments

  • kinekine Member Posts: 12,562
    += is not documented and "unsupported" operator (I cannot find the text on net, hard to search for +=). It is there just "by coincidence"...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • rocatisrocatis Member Posts: 163
    kine wrote:
    += is not documented and "unsupported" operator
    It's used in standard code (e.g. codeunit 80 for numbers and table 9051 for text) so it cannot be unsupported.

    -=, *= and /= are also used in standard code (only for numbers, of course).
    Brian Rocatis
    Senior NAV Developer
    Elbek & Vejrup
  • kinekine Member Posts: 12,562
    Yes, question is, why the developers at Microsoft are using undocumented unsupported operators... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • matttraxmatttrax Member Posts: 2,309
    Yeah, I stopped using += on text/code a while back after getting unanticipated results. Personally I like the readability of the X := X + Y syntax anyway.
Sign In or Register to comment.