Recent

Author Topic: IDE loses rferences to controls  (Read 762 times)

waltfair

  • New Member
  • *
  • Posts: 21
  • Walt Fair, PHD, PE. Engineer and software junkie
IDE loses rferences to controls
« on: April 27, 2023, 12:30:14 am »
IDE loses references. For example, I have a project with a form and a TStringGrid named grid1 and some code that extracts data from the grid.
It was working just fine, but then I saved and rebuilt the project and I get the error message "Identifier not found grid1". Even though
I made no changes to the project or code.
A similar thing has happened with other controls in other projects.

Any ideas as to how to avoid this problem and how to get my version working again without rewriting the whole thing?
I checked the code and the controls are listed in the Form declaration.

I've tried deleting the control and re adding it, as well as renaming t in the IDE to no avail.
« Last Edit: April 27, 2023, 12:35:28 am by waltfair »

Handoko

  • Hero Member
  • *****
  • Posts: 5158
  • My goal: build my own game engine using Lazarus
Re: IDE loses rferences to controls
« Reply #1 on: April 27, 2023, 05:31:59 am »
Hello waltfair,
Welcome to the forum.

I've been using Lazarus for a long time, never experienced the problem like you said. Actually yes, but that only happened because I manually edited the *.lfm files.

If you want, maybe you can provide us the source files so we can try to inspect and repair them for you. If the problem often happens on you, you may need to reinstall your Lazarus and maybe send a report to the bugtracker:
https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues
« Last Edit: April 27, 2023, 05:34:01 am by Handoko »

cdbc

  • Hero Member
  • *****
  • Posts: 1090
    • http://www.cdbc.dk
Re: IDE loses rferences to controls
« Reply #2 on: April 27, 2023, 09:43:56 am »
Hi
Just had one of those pestering situations  >:(
Look for a typo in one of your variable names  ;)
Happens if you're refactoring or renaming classes...
Hth - Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

waltfair

  • New Member
  • *
  • Posts: 21
  • Walt Fair, PHD, PE. Engineer and software junkie
Re:[Solved] IDE loses rferences to controls
« Reply #3 on: April 30, 2023, 07:45:49 pm »
I solved the problem by adding the Form variable to the grid as Form1.grdi1 and all works just fine.

Why I need the form variable in the code for the Form class itself, I don't understand, but thanks for the replies, they at least got me thinking.

Regards, Walt

eljo

  • Sr. Member
  • ****
  • Posts: 468
Re:[Solved] IDE loses rferences to controls
« Reply #4 on: April 30, 2023, 11:13:45 pm »
I solved the problem by adding the Form variable to the grid as Form1.grdi1 and all works just fine.

Why I need the form variable in the code for the Form class itself, I don't understand, but thanks for the replies, they at least got me thinking.

Regards, Walt
provide some code from your description I guess that the procedure you are accessing the grid1 is not a method of Tform1. Using the variable (Form1) will lead to bugs.

TRon

  • Hero Member
  • *****
  • Posts: 2538
Re:[Solved] IDE loses rferences to controls
« Reply #5 on: April 30, 2023, 11:24:22 pm »
Why I need the form variable in the code for the Form class itself, I don't understand, but thanks for the replies, they at least got me thinking.
It is called scope. for more information on that topic see https://www.freepascal.org/docs-html/current/ref/refse116.html

For your case probably class scope, https://www.freepascal.org/docs-html/current/ref/refsu101.html#x240-26400016.6.3

But as user eljo wrote if you show some code then it is probably possible to explain it better what went wrong where exactly. So next time you encounter this error then please post some code that triggers that error.

 

TinyPortal © 2005-2018