It is necessary to alter - ready code for reading line by line, using - Readln / Writeln. In order not to load all files into memory ...
procedure multiplyStrings(src1, src2, dst: TStrings); var i, j: integer; begin dst.Clear; for i := 0 to src1.Count - 1 do begin for j := 0 to src2.Count - 1 do begin dst.Add(src1[i] + ';' + src2[j]); end; end; end; var lines1, lines2, destination: TStringList; begin lines1 := TStringList.Create; try lines2 := TStringList.Create; try lines1.LoadFromFile('первый файл'); lines2.LoadFromFile('второй файл'); destination := TStringList.Create; try // Вариант первый multiplyStrings(lines1, lines2, destination); // Вариант второй multiplyStrings(lines2, lines1, destination); destination.SaveToFile('новый файл'); finally destination.Fre; end; finally lines2.Free; end; finally lines1.Free; end; end; I do this (but I can’t do it completely):
procedure TForm1.Button18Click(Sender: TObject); var f1,f2,f3:TextFile; s,str:string; i:integer; begin if OpenDialog1.Execute then begin AssignFile(f1,OpenDialog1.FileName); Reset(f1); if OpenDialog2.Execute then begin AssignFile(f2,OpenDialog2.FileName); Reset(f2); AssignFile(f3, '\Save.txt'); Rewrite(f3); while not Eof(f1) do begin Readln(f1,s); Readln(f2,str); /// и тут не знаю как цикл переделать как в коде что выше.....? Writeln(f3,s); end; CloseFile(f1); CloseFile(f2); CloseFile(f3); end; end; end;
AssignFileorFileOpenBoth methods allow you to read a text file line by line, how to make a loop - there is a code from the question. think a little bit yourself, and afterwards go ask the site - Vladimir Klykov