procedure TForm1.exitClick(Sender: TObject); begin close; end;
procedure TForm1.selectClick(Sender: TObject); begin if (open.execute()) then begin label3.caption:=extractfilename(open.filename); label4.caption:=extractfiledir(open.filename); end;
end;
procedure TForm1.exchangeClick(Sender: TObject); var infile:textfile; s,s1,s2,s3,s4:string; fCounter,i:integer; file_path:string; sno1,sno2,sno3,sno4,:string; begin file_path:=label4.caption+label3.caption; if fileexists(file_path) then begin assignfile(infile,file_path); filemode:=0; reset(infile); fCounter:=0; while not eof(infile) do begin readln(infile,s); fCounter:=fCounter+1; i:=pos(',',s); s1:=copy(s,1,i-1); if s1='5411' then sno1:=s1; s2:=copy(s,i+1,length(s)-i); i:=pos(',',s2); sno2:=copy(s2,1,i-1); s3:=copy(s2,i+1,length(s2)-i); i:=pos(',',s3); sno3:=copy(s3,1,i-1); s4:=copy(s3,i+1,length(s3)-i); i:=pos(',',s4); sno4:=copy(s4,1,i-1); end; end; closefile(infile);
好好花点时间学一下Object Pascal的语言方面: var s1: TStringList; begin s1 := TStringList.Create; try if FileExists(filename) then begin s1.LoadFromFile(filename) //Put your processing code here! end; finally s1.Free; end; end;
----------------------------------------------
-