Recent

Author Topic: unit visibility  (Read 391 times)

Medhome

  • New Member
  • *
  • Posts: 27
unit visibility
« on: October 30, 2024, 07:39:58 pm »
Hi all,

Say we  have 3 units  : unit1, unit2, unit3. Do we have to  add unit1 in USES  of unit2 and unit3 even if tform in unit3 is inherited from tform of unit2

Regards
Med

TRon

  • Hero Member
  • *****
  • Posts: 3618
Re: unit visibility
« Reply #1 on: October 30, 2024, 07:44:36 pm »
The answer depends on whether or not both unit 2 and 3 requires something from unit1 and/or if unit1 requires something from unit2 and/or unit3.

in short: impossible to provide a precise answer without more knowledge.
This tagline is powered by AI

Medhome

  • New Member
  • *
  • Posts: 27
Re: unit visibility
« Reply #2 on: October 30, 2024, 07:50:21 pm »
UNIT 2 AND 1 REQUIRES SOMETHING  FROM UNIT1  AND  UNIT3 AND 2 ARE RELATED  (INHERITED)

MED 

TRon

  • Hero Member
  • *****
  • Posts: 3618
Re: unit visibility
« Reply #3 on: October 30, 2024, 08:04:50 pm »
Assuming that ..
UNIT 2 AND 1 REQUIRES SOMETHING  FROM UNIT1  AND  UNIT3 AND 2 ARE RELATED  (INHERITED)
(no need to shout btw  :) )

was actually meant as
Quote
unit 2 and 3 requires something from unit1

then ...
Code: Pascal  [Select][+][-]
  1. unit unit1;
  2. interface
  3. implementation
  4. end.
  5.  

Code: Pascal  [Select][+][-]
  1. unit unit2;
  2. interface
  3. uses
  4.   unit1;  // in case something from unit1 is needed in this units interface section
  5. implementation
  6. uses
  7.   unit1; // in case something from unit1 is only needed in this units implementation section
  8. end.
  9.  

Code: Pascal  [Select][+][-]
  1. unit unit3;
  2. interface
  3. uses
  4.   unit1,  // in case something from unit1 is needed in this units interface section
  5.   unit2;
  6. implementation
  7.   unit1,  // in case something from unit1 is only needed in this units implementation section
  8. end.
  9.  
.. so that the answer to your first question becomes positive.
« Last Edit: October 30, 2024, 08:17:18 pm by TRon »
This tagline is powered by AI

Medhome

  • New Member
  • *
  • Posts: 27
Re: unit visibility
« Reply #4 on: October 30, 2024, 08:12:33 pm »
Hi All,

Question CLOSED.

TRon

  • Hero Member
  • *****
  • Posts: 3618
Re: unit visibility
« Reply #5 on: October 30, 2024, 08:19:24 pm »
You can mark your question as being solved yourself (actually it is the only way), see also wiki Mark a thread as resolved
This tagline is powered by AI

Medhome

  • New Member
  • *
  • Posts: 27
[solved] Re: unit visibility
« Reply #6 on: November 02, 2024, 04:22:42 pm »
Hi all,

Say we  have 3 units  : unit1, unit2, unit3. Do we have to  add unit1 in USES  of unit2 and unit3 even if tform in unit3 is inherited from tform of unit2

Regards
Med

dsiders

  • Hero Member
  • *****
  • Posts: 1280
Re: [solved] Re: unit visibility
« Reply #7 on: November 02, 2024, 04:48:16 pm »
Hi all,

Say we  have 3 units  : unit1, unit2, unit3. Do we have to  add unit1 in USES  of unit2 and unit3 even if tform in unit3 is inherited from tform of unit2

Regards
Med

Add "[Solved]" to the first post instead.
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

 

TinyPortal © 2005-2018