Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2003.09.11;
Скачать: [xml.tar.bz2];

Вниз

Вопрос по 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 вся ветка

Форум: "Основная";
Текущий архив: 2003.09.11;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.44 MB
Время: 0.009 c
14-33735
Knight
2003-08-21 09:30
2003.09.11
Клиент форума


4-33838
Jungle
2003-07-13 01:12
2003.09.11
Как заблокировать доступ к диску (логическому или физическому)


6-33718
Skywalker
2003-07-10 18:15
2003.09.11
TWebBrowser


1-33634
lord
2003-08-30 22:36
2003.09.11
а что рекурсия в потоке не работает ?


14-33770
Opuhshii
2003-08-23 20:47
2003.09.11
OODB? Каково ваше мнение?





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский