Вниз
Скачать: CL | DM;

Вопрос по try...finally.   Найти похожие ветки 

← →
iNew ©   (2003-08-29 06:10) [0]

try
Source := FileOpen(FileName, fmShareDenyWrite);
if Source < 0 then
begin
FileClose(Source);
exit;
end;
DoSomething;
finally
FileClose(Source);
end;

Возможно ли использовать Exit в данном случае?


← →
Anatoly Podgoretsky ©   (2003-08-29 06:29) [1]

Использовать можно и нужно, но первый FileClose надо убрать.


← →
iNew ©   (2003-08-29 07:06) [2]

Но если его убрать выплонится ли FileClose, который после finally, ведь если Source < 0, то выполнится Exit.


← →
Anatoly Podgoretsky ©   (2003-08-29 07:12) [3]

Да обязательно выполнится, хоть нормально, хоть в случае ошибки.


← →
Song ©   (2003-08-29 08:37) [4]

2iNew © (29.08.03 06:10)

procedure Exit;

Description

The Exit procedure immediately passes control away from the current procedure. If the current procedure is the main program, Exit causes the program to terminate.

Exit will cause the calling procedure to continue with the statement after the point at which the procedure was called.

Note: Exit passes control away from the current procedure, not merely the current block. But Exit does not violate the flow of control dictated by a try..finally construct; if Exit is called inside the try clause, the finally clause is still executed.



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.014 c
3-33512
sargos
2003-08-19 03:22
2003.09.11
Как избежать лишний трафик?


14-33742
Кен
2003-08-19 04:25
2003.09.11
Где находится центр тяжести вращающегося гироскопа ? В той точке


9-33423
PEOPLE
2003-03-08 13:01
2003.09.11
СКАЖИТЕ КАК СДЕЛАТЬ КАРТИНКУ С 256 ЦВЕТАМИ ?


1-33580
pavel_guzhanov
2003-08-28 15:30
2003.09.11
Использование PrintDialog


1-33655
qwerty2
2003-09-01 16:39
2003.09.11
Как избавиться от песочных часов в курсоре




   Наверх