Concatenate Matrix x Vectors

3

I have the following values in a StringList:

 1111,2222
 3333,4444

I have another String list with values

 7777,8888
 9999,0000

I need to add the values of the second stringlist, concatenating in the same position in sequence of the first Example:

 1111,2222,7777,8888
 3333,4444,9999,0000

How do I add the contents of the second array of data in the first?

    
asked by anonymous 07.04.2017 / 03:18

2 answers

1

You will have to get before the largest list, say, the one with the highest amount of data, otherwise violation or List of Bounds will occur.

  for i := 0 to Pred(vLista1.Count) do
  begin
    vLista1.Strings[i] := vLista1.Strings[i] + ',' + vLista2.Strings[i];
  end;

In this way we are editing the First List with the data of the Second exactly in the same order as the data.

    
07.04.2017 / 13:21
0

See if it helps you

var
 oSL1: TStringList;
 oSL2: TStringList;
 iCont1,iCont2: Integer;
 sValor: String;
begin
  oSL1 := TStringList.Create;
  oSL2 := TStringList.Create;
  try
    oSL1.Add('1111,2222');
    oSL1.Add('3333,4444');

    oSL2.Add('7777,8888');
    oSL2.Add('9999,0000');

    for iCont1 := 0 to oSL1.Count-1 do
    begin
      for iCont2 := 0 to oSL2.Count-1 do          
        sValor := oSL1.Strings[iCont1]+','+oSL2.Strings[iCont2];
    end;
  finally
    FreeAndNil(oSL1);
    FreeAndNil(oSL2);
  end;
end;
    
07.04.2017 / 13:14