spaces within string (COMPRESSARRAY)

johnsogjjohnsogj Member Posts: 103
I cant seem to get spaces to stick in the 5th line of my array. The SellToAddr variable is of type "text". How can I get spaces in between the pieces of the 5th line?

SellToAddr[1] := "Sell-to Customer Name";
SellToAddr[2] := "Sell-to Customer Name 2";
SellToAddr[3] := "Sell-to Address";
SellToAddr[4] := "Sell-to Address 2";
SellToAddr[5] := "Sell-to City" + "Sell-to County" + "Sell-to Post Code";
SellToAddr[6] := "Sell-to Country/Region Code";
COMPRESSARRAY(SellToAddr);

thanks

Comments

  • kinekine Member Posts: 12,562
    Do you mean this?
    SellToAddr[5] := "Sell-to City" + ' ' + "Sell-to County" + ' ' + "Sell-to Post Code"; 
    

    Compressarray has another functionality: it will "compress" all array elements in a way, that if the element is empty, all elements behind it will be shifted to the beginning. It means:

    if you have this array:
    Array[1] := 'text1';
    Array[2] := '';
    Array[3] := 'text3';
    Array[4] := '';
    Array[5] := 'text5';
    

    after you do COMPRESSARRAY the reult will be:
    Array[1] := 'text1';
    Array[2] := 'text3';
    Array[3] := 'text5';
    Array[4] := '';
    Array[5] := '';
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • ara3nara3n Member Posts: 9,256
    Also take a look at FormatAddress Codeunit it already does formating of addresses for orders customers, etc etc.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • SuDSuD Member Posts: 102
    kine wrote: »
    Do you mean this?
    SellToAddr[5] := "Sell-to City" + ' ' + "Sell-to County" + ' ' + "Sell-to Post Code"; 
    

    Compressarray has another functionality: it will "compress" all array elements in a way, that if the element is empty, all elements behind it will be shifted to the beginning. It means:

    if you have this array:
    Array[1] := 'text1';
    Array[2] := '';
    Array[3] := 'text3';
    Array[4] := '';
    Array[5] := 'text5';
    

    after you do COMPRESSARRAY the reult will be:
    Array[1] := 'text1';
    Array[2] := 'text3';
    Array[3] := 'text5';
    Array[4] := '';
    Array[5] := '';
    

    Hello Kine,I want to Print Item."Vendor No." in a Report,with using of COMPRESSARRAY function.I mean i want to remove all lines having blank Vendor no..Any Idea?
  • vaprogvaprog Member Posts: 1,140
    Hi SuD,

    Please don't hijack old, only remotely related threads.

    You probably need to use
    IF Item."Vendor No." = '' THEN
      CurrReport.SKIP;
    
    in the OnAfterGetRecord of your Item DataItem.
    COMPRESSARRAY is not suitable for your purpose.
Sign In or Register to comment.