The code that you gave me works in the sence of it displays the address but, only displays the letters in the address not the number, and also you can type in any name and it will display the address. E.g.
The names in the list:
Katie
Andy
Elaine
Scott
You could type in Chris and it will still display one of the address. What ever name you type in it will display the last address that you have entered into the file.
I have tryed to change it but have got stuck. Could you please help me again.
If it helps hears the code for the form:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
details=record
name:string[30];
address:string[50];
end;
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Edit3: TEdit;
Edit4: TEdit;
Button2: TButton;
Button3: TButton;
procedure Edit1Change(Sender: TObject);
procedure Edit2Change(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
detailsrecord:details;
detailsfile:file of details;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Edit1Change(Sender: TObject);
begin
form1.detailsrecord.name:=edit1.text;
end;
procedure TForm1.Edit2Change(Sender: TObject);
begin
form1.detailsrecord.address:=edit2.text;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
with form1 do
begin
assignfile(detailsfile,'details.txt');
reset(detailsfile);
seek(detailsfile,filesize(detailsfile));
write(detailsfile,detailsrecord);
closefile(detailsfile);
end;
edit1.Text:='';
edit2.Text:='';
end;
procedure TForm1.Button2Click(Sender: TObject);
var line,name,address:string;
f:textfile;
begin
assignfile(f,'details.txt');reset(f);
address:='';
repeat
readln(f,line);
name:=copy(line,1,pos(' ',line)-1);
address:=copy(line,pos(' ',line)+1,length(line));
until (lowercase(name)=lowercase(edit3.Text)) or (eof(f));
if address='' then address:='no name found';
edit4.Text:=address;
closefile(f);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
edit3.Text:='';
edit4.Text:='';
end;
end.