Author Topic: Accessing Procedure in another Unit  (Read 1066 times)


  • Jr. Member
  • **
  • Posts: 93
Accessing Procedure in another Unit
« on: September 08, 2021, 02:35:25 am »
I have an application that seems, to me, to be behaving in a strange way when I call a procedure in another unit within the application.  The situation is as follows:-

Unit1 references Unit2 in its interface/units area.
Unit1 calls Procedure XX in Unit2
Procedure XX has the line <StringGrid1.Options:=StringGrid1.Options + [goEditing]> (referring to StringGrid in Unit2 Form;

If I run the program with Ctr/Shift F9 then the program works OK.  However, if I run it with just F9 it throws up an error (because Unit2 form has not been assigned).

Can anyone explain (briefly) why the difference in behavior?  If I open Form2 first, it works fine in both methods.
« Last Edit: September 08, 2021, 02:37:22 am by Badger »

If at first you don't succeed - you're running about average!

I'm using Windows 10 Lazarus v2.0.10


  • Sr. Member
  • ****
  • Posts: 384
Re: Accessing Procedure in another Unit
« Reply #1 on: September 08, 2021, 09:33:53 am »
Post exact error you are getting.
Even better: make small demo project where this error is manifested and post it here.


  • Hero Member
  • *****
  • Posts: 9025
Re: Accessing Procedure in another Unit
« Reply #2 on: September 08, 2021, 10:19:22 am »
I don't know what you are doing. The attached demo hopefully does what you describe (except: changing the grid color rather than setting it to be editable), and it works correctly.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...


TinyPortal © 2005-2018