unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function changestr(str:string):string;
var
temstr:string;
begin
result:='';
temstr:=copy(str,4,3);
temstr:=temstr+'|'+copy(str,10,3);
temstr:=temstr+'|'+copy(str,13,2);
result:=temstr;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
F: textfile;
str: string;
n1,n2,n3:integer;
strList1, strList2: TstringList;
begin
strList1 := TstringList.Create;
try
assignfile(F, 'f:/f1.txt');
reset(F);
while not Eof(F) do
begin
readln(F,str);
str:=changestr(str);
strList1.Add(str);
end;
strList1.SaveToFile('F:/f2.txt');
closefile(F);
finally
freeandnil(strList1);
end;
end;
end;
其实就是写一个函数九成.