Здравствуйте, столкнулся с такой проблемой при открытии типизированного файла все происходит нормально, но когда нажимаю кнопку отмена вместо открыть появляется ошибка I/O error 103
procedure TForm1.N5Click(Sender: TObject); // Open file
type
zapic=record
tablica:string[1];
fynkci9:string[200];
kolvo_strok:integer;
kolvo_el:integer;
end;
var
j:integer;
ft:file of zapic;
s:zapic;
m:string;
begin
OpenDialog1.Title:='Открыть файл';
openDialog1.Filter :='Файлы таблицы истинности|*.tabl';
if OpenDialog1.Execute then
begin
fname:=OpenDialog1.FileName;
AssignFile(ft,fname);
Reset(ft);
end
else ShowMessage('Открытие файла остановлено');
j:=0;
read(ft,s);
stringgrid2.RowCount:=s.kolvo_strok;
while not eof(ft) do
begin
read(ft,s);
stringgrid2.Cells[0,j]:=s.tablica;
inc(j);
end;
edit1.Text:=inttostr(s.kolvo_el);
edit2.Text:=s.fynkci9;
closeFile(ft);
end;
if OpenDialog1.Execute then
procedure TForm1.Timer1Timer(Sender: TObject);
begin
StringGrid2.TopRow := StringGrid1.TopRow;
end;
Извиняюсь за созданную тему решение было найденно добавлением оператора exit
.....
else begin ShowMessage('Открытие файла остановлено'); exit; end;
....
begin? Никаких Exit-ов, заметь... И код читается лучше... Кстати, ошибки при чтении тоже надо бы обрабатывать, нельзя быть уверенным на 100%, что их не будет...
OpenDialog1.Title:='Открыть файл';
openDialog1.Filter :='Файлы таблицы истинности|*.tabl';
if OpenDialog1.Execute then
begin
fname:=OpenDialog1.FileName;
AssignFile(ft,fname);
Reset(ft);
j:=0;
read(ft,s);
stringgrid2.RowCount:=s.kolvo_strok;
while not eof(ft) do
begin
read(ft,s);
stringgrid2.Cells[0,j]:=s.tablica;
inc(j);
end;
edit1.Text:=inttostr(s.kolvo_el);
edit2.Text:=s.fynkci9;
closeFile(ft);
end
else ShowMessage('Открытие файла остановлено');
end;
мммм..... Спасибо, действительно так гораздо лучше и понятней
China Syntroid
Why not settling on games that is fun and at the same time your earning. Well it'll make suspense because the game is well but dude just try it and it gave me hope while pandemic is real rn. https://fashion4home.net/best-bonuses-in-casino/