TStringlist as Delphi

Can I use TStringlist in the code editor for delimitedtext?
I tried commatext, but has his limits when a string has more comma's than needed

Example : 1,2,3,My dog is tiny, but very friendly,ww,ee,rr

result : 7 entries, but should be 6

Comments

  • edited February 2019
    Can I use TStringlist in the code editor for delimitedtext?
    I tried commatext, but has his limits when a string has more comma's than needed

    Example : 1,2,3,My dog is tiny, but very friendly,ww,ee,rr

    result : 7 entries, but should be 6


    Test:
    procedure Test();
    var
      i    : Integer;                                   
      fSL  : TStringList;
      fStr : String;
    begin
      
      fStr := '';                                 
      fSL := TstringList.Create();
      try
        fSL.CommaText := '1,2,3,"My dog is tiny, but very friendly",ww,ee,rr';
        for i := 0 to fSL.Count - 1 do
          fStr := Format('%s%3d. %s'#10,[fStr, i + 1, fSL[i]]);                                                      
        fStr := fStr + '=======' + #10'Total = ' + VarToStr(fSL.Count);
        ShowMessage('Comma text: '+ fSL.CommaText
                    +#10'-----'
                    +#10 + fStr);
      finally
        fSL.Free();
      end;                  
    end;
    

Leave a Comment