Recent

Author Topic: [Solved] Interpreting compiler debug messages  (Read 718 times)

Centauri

  • New Member
  • *
  • Posts: 25
[Solved] Interpreting compiler debug messages
« on: April 07, 2020, 03:31:22 pm »
Trying to work out what the debugger is telling me with a compiling error after I added a procedure to my current project, and a few suggestions on how to trace the issue to find the problem is in order.  The procedure I added is:
Code: Pascal  [Select][+][-]
  1. procedure TCustomerForm.DataSourceCustDataChange(Sender: TObject);
  2. var
  3.   i,j: integer;
  4. begin
  5.   For i:= 0 to PageControl1.ActivePage.ComponentCount-1 do
  6.    If PageControl1.ActivePage.Components[i] is TCustFrame then
  7.     CustActiveFrame:= (PageControl1.ActivePage.Components[i] as TCustFrame);
  8.   If CustActiveFrame.CheckBoxEditMode.Checked then exit; // Tab in edit mode
  9.   With CustActiveFrame do
  10.   begin
  11.       For j:= 0 to 43 do
  12.        begin
  13.            with TMemo(FindComponent('Memo'+IntToStr(j))) do
  14.            begin
  15.                Text:=DataModule1.DataSourceCust.DataSet.Fields[j].DisplayText;
  16.            end;
  17.        end;
  18.   end;
  19. end;                
This is to get the contents of all fields in my customer dBase table, located in DataModule1, accessed via the datasource dataset, and write them to a series of TMemo boxes located within a frame which is added to dynamically generated tabsheets at runtime (the tabs creation & frame with memo boxes adding works fine), and is fired by the OnDataChange event of the table to update the memo boxes when the record pointer moves.
When I compile, it throws up an error of:
Code: Text  [Select][+][-]
  1. .. raised exception class 'EReadError' with message:
  2. Invalid value for property
  3. At address 441C08
The debugger opens up the LResources unit and highlights line 3156 which reads:
Code: Pascal  [Select][+][-]
  1. Reader.ReadRootComponent(Instance);
Hovering over Instance shows that it is holding <TDATAMODULE1>, so there is some sort of error there, but I can't see what it might be.
Any advice on how to interpret things further would be helpful.
Thanks in advance
« Last Edit: April 08, 2020, 01:14:23 pm by Centauri »

jamie

  • Hero Member
  • *****
  • Posts: 6077
Re: Interpreting compiler debug messages
« Reply #1 on: April 07, 2020, 11:34:18 pm »
I am going to take a wild guess here but I don't understand why it crashes at compile time...

Anyways.. The FindComponent could be wrong because your starting number is 0 and normally if you use the IO for auto numbering it should start at 1. So talking that into account I would say it returns a Nil object on first go round but you are not testing for nil objects you are just jumping into the fire..

 as for the rest I'll have to look some more..
The only true wisdom is knowing you know nothing

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9754
  • Debugger - SynEdit - and more
    • wiki
Re: Interpreting compiler debug messages
« Reply #2 on: April 07, 2020, 11:45:09 pm »
"Reader.ReadRootComponent" is normally used to read a Form or DataModule from the LFM. That is read the values you did set in the ObjectInspector.

But that would only happen when a TForm or TDataModule (or similar) is created.
I do not know if that happens for you. Could be.
Could also be, that the Reader is used to read data from elsewhere.....

You should be able to open the Stack (View > Debug windows > Stack ...).
You could copy and paste that.
You could also see, what line in your code is calling the method that crashes.



Also to a clean build / Or project > clean up / then build.

Centauri

  • New Member
  • *
  • Posts: 25
Re: Interpreting compiler debug messages
« Reply #3 on: April 08, 2020, 01:13:53 pm »
Ok, it would seem I was mistaken as to what part of the compile / run process was throwing up the error - I had thought that the error was happening before the exe file was created and run, but found out it was actually a run time error.  Seems to be related to an attempt to call a event handler procedure in one unit from an event in another - to avoid confusing this post, will mark this as solved & start a new post. Thanks peoples.

 

TinyPortal © 2005-2018