点一个按钮,想打开个文件在CHART上,我需要打开2种文件,一个是DAT,一个是BMP,但是我的程序只能打开BMP,找不到DAT啊 ,不知道怎么回事,希望大家能帮我看看,谢谢
procedure TMainForm.Action1Execute(Sender: TObject);var
f:TextFile;
str:string;
begin
opendialog1.Filter:='datÎļþ(*.dat) |*.dat |bmpÎļþ(*.bmp) |*.bmp';
opendialog1.Execute;
str:=copy(opendialog1.FileName,length(opendialog1.FileName)-2,3);
if str='dat' then
begin
Assignfile(f,OpenDialog1.FileName);
Reset(f);
try
while not Eof(f) do
begin
Readln(f,Rx,Ry );
PointsA.AddXY(Rx, Ry);
end;
finally
closefile(f);
end;
end;
if str='bmp' then
begin
PicFileName := opendialog1.FileName;
cht1.BackImage.LoadFromFile(PicFileName);
stat1.Panels[0].Text := PicFileName;
end;
end;
procedure TMainForm.Action1Execute(Sender: TObject);var
f:TextFile;
str:string;
begin
opendialog1.Filter:='datÎļþ(*.dat) |*.dat |bmpÎļþ(*.bmp) |*.bmp';
opendialog1.Execute;
str:=copy(opendialog1.FileName,length(opendialog1.FileName)-2,3);
if str='dat' then
begin
Assignfile(f,OpenDialog1.FileName);
Reset(f);
try
while not Eof(f) do
begin
Readln(f,Rx,Ry );
PointsA.AddXY(Rx, Ry);
end;
finally
closefile(f);
end;
end;
if str='bmp' then
begin
PicFileName := opendialog1.FileName;
cht1.BackImage.LoadFromFile(PicFileName);
stat1.Panels[0].Text := PicFileName;
end;
end;
你可以在 Readln(f,Rx,Ry ); 设置端点看看