[Solved] Delphi Split-Merge String without seperators?


There is no built-in functionality to do that, since you throw away information (the length of each string). So that information have to be stored somewhere.

You could use a TStringList descendant :

Interface

  TMyStrings = class(TStringList)
  protected
    function GetTextStr: string; override;
  end;

Implementation

{ TMyStrings }

function TMyStrings.GetTextStr: string;
var
  Element: String;
begin
  Result := '';
  for Element in Self do
    Result := Result + Element;
end;

And how to use it :

procedure TForm5.FormCreate(Sender: TObject);
var
  MyStrings : TMyStrings;
begin
  MyStrings := TMyStrings.Create;

  MyStrings.Add('0');
  MyStrings.Add('012');
  MyStrings.Add('23');
  MyStrings.Add('458');
  MyStrings.Add('022'); // These values are example of.
  MyStrings.Add('001');
  MyStrings.Add('0125');
  MyStrings.Add('250');
  MyStrings.Add('859');
  MyStrings.Add('9');

  Caption := MyStrings.Text;
  FreeAndNil(MyStrings);
end;

With this in hand you can get your list as a joined string, and you still have the original information about each string.

9

solved Delphi Split-Merge String without seperators?