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

Вниз

Обработка исключений   Найти похожие ветки 

 
-=Mike=-   (2006-01-18 03:50) [0]

В своем проекте я использую модуль err.pas. Много где пользуюсь процедурой Abort.
Но возникает одна проблема: т.к. в KOL нет обработчика исключений по умолчанию как например в VCL это сделано повторением в цикле операторов:
       try
         HandleMessage;
       except
         HandleException(Self);
       end;


Т.о. процедура Abort приводит к аварийному завершению программы.

Подскажите, как можно решить эту проблему???


 
ECM ©   (2006-01-18 14:30) [1]

Можно так же как и в VCL  :))
Добавляем в проект новый Unit:

unit HandledRun;

interface
uses Windows,KOL;

procedure RunSafe( var AppletWnd: PControl );

implementation

procedure RunSafe( var AppletWnd: PControl );
begin
 AppletRunning := True;
 Applet := AppletWnd;
 AppletWnd.CreateWindow; //virtual!!!
 while not AppletTerminated do
 begin
   try
     WaitMessage;
     AppletWnd.ProcessMessages;
     {$IFDEF USE_OnIdle}
     ProcessIdle( AppletWnd );
     {$ENDIF}
   except
   // Пишем тут обработчик (если нужен)
   end;
 end;
 if AppletWnd <> nil then
   TerminateExecution( AppletWnd );
end;

end.


Открываем файл ProjectName_1.inc и добавляем две строки:

{ xxx_1.inc
 This file is for you. Place here any code to run it
 just following Applet creation (if it present) but
 before creating other forms. E.g., You can place here
 <IF> statement, which prevents running of application
 in some cases. TIP: always use Applet for such checks
 and make it invisible until final decision if to run
 application or not. }

 RunSafe(Form1.Form );
 Halt(0);


собственно всё...:))


 
ECM ©   (2006-01-18 14:34) [2]

З.Ы. сорри (опечатка) - надо использовать не ProjectName_1.inc а
ProjectName_3.inc иначе доп. формы никогда не появятся ... :))


 
-=Mike=-   (2006-01-18 19:59) [3]

Спасибо!
Попробую этот вариант


 
Thaddy   (2006-01-18 21:03) [4]

Another usefull trick is this:

try
 //your code
except
//hardware interrupt
asm
  int 3
end;
end;

Then you can examine the callstack to find the last working routine...



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

Форум: "KOL";
Текущий архив: 2006.11.05;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.45 MB
Время: 0.042 c
2-1161111936
DROWSY
2006-10-17 23:05
2006.11.05
Ретро вопрос. :)


2-1161430828
nokk
2006-10-21 15:40
2006.11.05
время gmt


11-1137519814
Vladimir Kladov
2006-01-17 20:43
2006.11.05
ProjMover


15-1160605343
learner
2006-10-12 02:22
2006.11.05
SelectDirectory и новые нити в проекте


15-1160657889
oldman
2006-10-12 16:58
2006.11.05
Ну вот и все... Как дальше жить?





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский