если создали процедуру типа:
Код:
procedure FlRead;
begin
// тут процедура чтения из файла и запись в Edit5
end;
то она не увидит Edit5 на форме, нужно объявлять процедуру внутри класса формы:
Код:
type
TForm1 = class(TForm)
Edit5: TEdit;
// и т.д........
procedure FlRead;
// и т.д........
end;
procedure TForm1.FlRead;
var
myFile: TextFile;
text: string;
begin
AssignFile(myFile,'f.txt');
Reset(myFile);
while not Eof(myFile) do
begin
ReadLn(myFile, text);
end;
CloseFile(myFile);
Edit5.Text := text;
end;
или можно сделать так:
Код:
function FlRead(f_name: string): string;
var
myFile: TextFile;
text: string;
begin
AssignFile(myFile,f_name);
Reset(myFile);
while not Eof(myFile) do
begin
ReadLn(myFile, text);
end;
CloseFile(myFile);
Result := text;
end;
тогда не нужно будет объявлять процедуру в TForm1, а можно будет использовать функцию
FlRead в любом месте кода (главное что бы она была выше используемого кода):
Код:
Edit5.Text := FlRead('f.txt');