F
fbc-gc
Unregistered / Unconfirmed
GUEST, unregistred user!
程序代码:
procedure TForm2.BitBtn3Click(Sender: TObject);
begin
form2.Visible:=false;
form1.Enabled:=true;
form1.Visible:=true;
form1.Timer1.Enabled:=true;
end;
procedure TForm2.FormShow(Sender: TObject);
var
line:string[40];
begin
form2.ComboBox1.Items.Clear;
form2.Edit1.Clear;
form2.Edit2.Clear;
AssignFile(word_file,WordFileName);//第一次执行时无错,调用opendialog后出错
try
reset(word_file);
except
on EInOutError do
begin
showmessage('缺少配置文件'+WordFileName);
Application.Terminate;
end;
end;
while(not eof(word_file)) do
begin
readln(word_file,line);
if (line<>'') then
form2.ComboBox1.Items.Add(copy(line,1,pos('=',line)-1));
end;
closefile(word_file);
end;
procedure TForm2.BitBtn4Click(Sender: TObject);
begin
if (form2.Edit2.Text='') or (form2.Edit2.Text='') then
begin
showmessage('请填写全部信息');
exit;
end;
Assignfile(word_file,wordfilename);
try
Append(word_file);//到此出错!!
except
on EInOutError do
begin
showmessage('缺少配置文件'+wordFileName);
Application.Terminate;
end;
end;
writeln(word_file,form2.Edit2.Text+'='+form2.Edit1.Text);
closefile(word_file);
end;
procedure TForm2.Button1Click(Sender: TObject);
var
PD:TOpenDialog;
begin
PD:=TOpenDialog.Create(form2);
PD.Filter:='词库文件|*.wrd';
if PD.Execute then
form2.Edit1.Text:=PD.FileName;
PD.Destroy;
end;
奇怪的问题:
我动态的创建了一个TOpenDialog,用它来得到一个文件的路径,将其保存到form2.edit1.text
里,然后点击button2时,通过form2.edit1.text将TOpenDialog得到的文件路径保存到一个文件
里(word_file).但当执行到Append(word_file)时出现错误:invalid filename.但未调用
OpenDialog前可以打开这个文件并能读出信息(读完信息后closefile(word_file));
procedure TForm2.BitBtn3Click(Sender: TObject);
begin
form2.Visible:=false;
form1.Enabled:=true;
form1.Visible:=true;
form1.Timer1.Enabled:=true;
end;
procedure TForm2.FormShow(Sender: TObject);
var
line:string[40];
begin
form2.ComboBox1.Items.Clear;
form2.Edit1.Clear;
form2.Edit2.Clear;
AssignFile(word_file,WordFileName);//第一次执行时无错,调用opendialog后出错
try
reset(word_file);
except
on EInOutError do
begin
showmessage('缺少配置文件'+WordFileName);
Application.Terminate;
end;
end;
while(not eof(word_file)) do
begin
readln(word_file,line);
if (line<>'') then
form2.ComboBox1.Items.Add(copy(line,1,pos('=',line)-1));
end;
closefile(word_file);
end;
procedure TForm2.BitBtn4Click(Sender: TObject);
begin
if (form2.Edit2.Text='') or (form2.Edit2.Text='') then
begin
showmessage('请填写全部信息');
exit;
end;
Assignfile(word_file,wordfilename);
try
Append(word_file);//到此出错!!
except
on EInOutError do
begin
showmessage('缺少配置文件'+wordFileName);
Application.Terminate;
end;
end;
writeln(word_file,form2.Edit2.Text+'='+form2.Edit1.Text);
closefile(word_file);
end;
procedure TForm2.Button1Click(Sender: TObject);
var
PD:TOpenDialog;
begin
PD:=TOpenDialog.Create(form2);
PD.Filter:='词库文件|*.wrd';
if PD.Execute then
form2.Edit1.Text:=PD.FileName;
PD.Destroy;
end;
奇怪的问题:
我动态的创建了一个TOpenDialog,用它来得到一个文件的路径,将其保存到form2.edit1.text
里,然后点击button2时,通过form2.edit1.text将TOpenDialog得到的文件路径保存到一个文件
里(word_file).但当执行到Append(word_file)时出现错误:invalid filename.但未调用
OpenDialog前可以打开这个文件并能读出信息(读完信息后closefile(word_file));