我的程序中的這個片段首先將客戶廣告給文本文件(在公共變量中聲明)並將其保存到texfile。 onbutton1click是檢索字符串多數民衆贊成在編輯框,並返回相關的客戶細節備忘錄。添加客戶工作正常,並添加到文本文件,但是當我搜索它沒有返回備忘錄,只是備忘錄標題,備忘錄1。任何方式我可以解決這個問題?對不起,這是一個新手。搜索文本文件的寫作結果備忘錄,lazarus
procedure TForm2.btnsaveClick(Sender: TObject);
begin
cusfname:= edit1.text ;
cuslname:= edit2.text;
adress:= edit3.text;
phone:= edit4.text;
password:= edit5.Text;
AssignFile(F, 'Data.txt');
append(F);
WriteLn(F, cusfname);
WriteLn(F, cuslname);
WriteLn(F, adress);
WriteLn(F, phone);
WriteLn(F, password);
CloseFile(F);
end;
procedure TForm2.Button1Click(Sender: TObject);
var
SearchFile : Textfile;
found: boolean;
search: string;
begin
search := edit1.text;
Assignfile(SearchFile, 'data.txt');
Reset(SearchFile);
found:= false;
repeat
found:= search = phone
until eof(searchfile) or found;
if found then
memo1.append(phone);
memo1.append(cusfname);
memo1.append(adress);
if not found then
showmessage('member not found');
end;
begin reset(searchfile); Assignfile(SearchFile,'data.txt'); 重置(SearchFile); found:= false; search:= edit1.text; 重複 read(searchfile,phone); read(searchfile,cusfname); read(searchfile,address); found:= search = phone 直到eof(searchfile)或找到; if if then memo1.append(phone); memo1.append(cusfname); memo1.append(adress); closefile(searchfile); if not found then showmessage('member not found'); – haz 2010-10-25 10:09:16
爲什麼在寫入時使用read()和writeLN()? – 2010-10-25 11:42:06