Execution (solved) lazarus / 10-Designer ---------------------------------------------------------------------- Degibbo · 2017-08-03 01:48 G'day all, Well with a lot of help from the resident guru's my ex Delphi program now compiles OK, so thanks for all the assistance. When I try and run the program I get the infamous "Execution Stopped" box after about three seconds, and nothing showing.  I tried inserting break- points to determine where it is getting hung-up, but none are ever reached. What is the exact execution order for procedures in the program, what gets called first? I suspect that it is falling over before it even gets to the main program, but how to debug? "Execution Stopped" might be accurate, but not very helpful! Cheers & thanks yet again, DG ---------------------------------------------------------------------- RAW · 2017-08-03 01:53 Do you mean this ??? ---------------------------------------------------------------------- Degibbo · 2017-08-03 02:46 G'day Raw, Yep, that looks like it. A break-point set at the top of the Create procedure is never executed. So, is there a way to investigate what happens in the Initialization, or trace where the execution is stopped  and why? Thanks, DG ---------------------------------------------------------------------- RAW · 2017-08-03 03:09 Is there any code inside Initialization and at the beginning of the LPR ? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i UNIT Unit1; {$MODE OBJFPC}{$H+}{$J-} Interface USES  Classes, SysUtils, Forms, Controls;  TYPE  TForm1 = Class(TForm)   End;  VAR  Form1: TForm1; Implementation {$R *.LFM}  INITIALIZATION  ?????????????? FINALIZATION END. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i PROGRAM Project1; {$MODE OBJFPC}{$H+}{$J-}  USES  {$IFDEF UNIX}{$IFDEF UseCThreads}   cThreads,  {$ENDIF}{$ENDIF}   Interfaces,   Forms,   Unit1;   {$R *.RES} BEGIN ??????????  RequireDerivedFormResource:= True;  Application.Initialize;  Application.CreateForm(TForm1, Form1);  Application.Run;END. ---------------------------------------------------------------------- RAW · 2017-08-03 03:16 Can you reproduce the ERROR with a little test program that uses the same starting routines ??? EDIT: do you see INTERFACES inside the LPR... ? ---------------------------------------------------------------------- Degibbo · 2017-08-03 23:18 G'day Raw, Interestingly the main program does not appear to have a defined "INITIALIZATION" or "FINALIZATION" section! Maybe that is the problem?? Also the LPR has no "INTERFACES" section, just a users clause and begin   Application.Initialize;   Application.CreateForm(TMainForm, MainForm);   Application.Run;   MainForm.Free; end. I will try break-points in the LPR to see where it gets to. I will also dummy up something and try your suggestion. Cheers & thanks, DG ---------------------------------------------------------------------- RAW · 2017-08-03 23:30 QuoteInterestingly the main program does not appear to have a defined "INITIALIZATION" or "FINALIZATION" section! This is optional you don't need it, but you can use it if you want...  LPR: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  MainForm.Free;This looks crazy .... weird... something like that...  You need probably INTERFACES and you don't need MAINFORM.FREE...  EDIT: Normally you should get a warning if you don't have INTERFACES inside the main program. ---------------------------------------------------------------------- Degibbo · 2017-08-04 01:50 G'day, OK, I cut down the main program to just a button and an editbox. It ran OK, no execution stop. Interestingly if I comment out the calls in the LPR file and with the original main file I still get the error, so I guess that is the fall-back position for anything that doesn't work as expected.  So I still can't confirm that the problem is with the LPR or the main file The next step I guess is to comment out everything step by step and see if I can get it to run. Cheers, DG ---------------------------------------------------------------------- RAW · 2017-08-04 04:40 Hi Degibbo, if the debugger couldn't help then it's probably the best idea to comment out everything that is inside OnCreate, OnResize, OnShow, OnActivate, OnPaint and everything that is at the beginning of the LPR-file. That way you'll sooner or later find the problem... Don't give up... it's usually something very simple... ...the wood for the trees...  btw: Did you check the project options: compiler options: config and target: is there everything right? Right widgetset, platform and so on... ? Another way would be to use a very simple logging... (if there is a real exception...) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Procedure Log(strInfo: String);  Var   slSave : TStringlist;   strFile: String;   strLog : String;   wnd    : TForm;   lab    : TLabel; Begin  Try   Try    strFile:= Application.Location+'Error.log';     slSave:= TStringlist.Create;     Try      If FileExists(strFile)      Then     Begin        Try         slSave.LoadFromFile(strFile);        Except        End;       End;       slSave.Text:=        DateTimeToStr(Now) +sLineBreak+       strInfo            +sLineBreak+       ''               +sLineBreak+       slSave.Text;       strLog:= slSave.Text;      slSave.SaveToFile(strFile);     Finally      slSave.Free;     End;   Except   End;    If strLog = '' Then strLog:= strInfo;    wnd:= TForm.Create(Nil);    Try     wnd.BorderStyle          := bsSizeable;     wnd.BorderIcons          := [biSystemMenu, biMaximize];     wnd.Caption              := Application.Title+'.log';     wnd.Constraints.MinHeight:= 200;     wnd.Constraints.MinWidth := 300;     wnd.Height               := 300;     wnd.Width                := 400;     wnd.AutoScroll           := True;     wnd.HorzScrollBar.Visible:= False;     wnd.Position             := poDesktopCenter;      lab             := TLabel.Create(wnd);     lab.Align       := alClient;     lab.Caption     := strLog;     lab.Font.Size   := 15;     lab.Font.Quality:= fqAntialiased;     lab.Font.Style  := [fsBold];     lab.Transparent := True;     lab.WordWrap    := True;     lab.AutoSize    := False;     lab.Parent      := wnd;      wnd.ShowModal;    Finally     wnd.Release;     wnd:= Nil;    End;  Except  End; End;  Procedure TForm1.FormCreate(Sender: TObject); Begin  Try   // ....   Except   On E: Exception   Do Log('FormCreate'+sLineBreak+E.ClassName+sLineBreak+E.Message);  End; End; ---------------------------------------------------------------------- Degibbo · 2017-08-04 04:46 G'day, Moving on:  As there doesn't seem to be a way to comment-out code that contains comments, it is a slow job stripping down my main file (about 1000 lines of code). As expected, I get all sorts of errors, such as an EReadError at 100049635.  Is there an easy way, from this information, to get to the actual source code line that caused the error? Cheers & thanks, DG ---------------------------------------------------------------------- RAW · 2017-08-04 05:01 Do you read from a stream ??? (EReadError) Use an easy exception handling then you'll know where the problem is... ---------------------------------------------------------------------- Degibbo · 2017-08-09 03:29 G'day, Well the execution failure has bee "fixed" but not explained. It turned out that any call that was likely to fail caused the error, even if it was not actually called!  The calls were to hardware drivers where the hardware was not fitted. Temporary comment-outing of the lines solved the problem. Thanks for all the help, ideas & encouragement. Cheers, DG ---------------------------------------------------------------------- molly · 2017-08-09 22:31 Quote from: RAW on August 04, 2017, 01:30:30 amQuoteInterestingly the main program does not appear to have a defined "INITIALIZATION" or "FINALIZATION" section! This is optional you don't need it, but you can use it if you want...  @RAW: sorry in advance for the nitpick but wanted to make sure there is no misunderstanding when someone reads through. It is optional to have a initialization or finalization section inside your main program file ? Either we have a different understanding of what is meant by main program or i would very much like to see how that is able to compile. For me "main program" means that particular file that starts with the reserved word "program". ---------------------------------------------------------------------- Degibbo · 2017-08-09 23:47 G'day Raw, Thanks for the nitpic.  You are right of course.  What I refer to as the "main program" is the unit that is called first, and everything else is called from it (my "master"). I guess that stems from my structural ignorance, and so of course the "main" program is actually the LPR file. Sorry about the confusion. Cheers & thanks, DG ---------------------------------------------------------------------- RAW · 2017-08-10 00:13 Hey molly  ... btw: I attached in "Reply #3" a unit ... Yes he wrote main program... I can see that now...  Maybe I overlooked that a little bit... just a little bit... only to give you the chance to nitpick... (What do you mean you cannot compile INITIALIZATION inside your LPR... It's probably your computer... something is wrong with it... obviously...) @Degibbo Quote...and everything else is called from it (my "master"). Oh thanks, but unfortunately I'm not a master, not even a "master"... and it's molly's nitpick... so molly shame on you...  Ok, Ok, it's more a matter of exactness not really a nitpick... whatever... (heretic..  ) QuoteSorry about the confusion. No problem at all, I'm not confused... Nice to hear that you've got it running...