Hi!
I came across a stupid problem and I really have no idea why it arises. There is the following type declaration in my code:
db_settings=record
default_db:boolean;
filename:string[100];
server:string[100];
db:string[100];
user:string[100];
password:string[100];
end;
Then I write these things to a file:
procedure TForm2.Button10Click(Sender: TObject);
var
db_sett:db_settings;
dbsfile:file of db_settings;
begin
assignfile(dbsfile,'db_settings.dat');
with db_sett do
begin
filename:=edit1.Text;
server:=edit2.Text;
db:=edit3.Text;
user:=Edit4.Text;
password:=Edit5.Text;
if radiobutton1.Checked then default_db:=true else default_db:=false;
rewrite(dbsfile);
end;
end;
The next code reads from that file:
procedure TForm2.FormCreate(Sender: TObject);
var
db_sett:db_settings;
dbsfile:file of db_settings;
begin
if fileexists('db_settings.dat') then
begin
assignfile(dbsfile,'db_settings.dat');
reset(dbsfile);
read(dbsfile,db_sett);
with db_sett do
begin
Edit1.Text:=filename;
Edit2.Text:=server;
Edit3.Text:=db;
Edit4.Text:=user;
Edit5.Text:=password;
if default_db then radiobutton1.Checked:=true else radiobutton2.Checked:=true;
end;
end;
end;
And here is the problem - I get 'Read beyon end of file.' each time the procedure tries to read from the file.