I am using the BeforSignup in the AfterSignup unit in order to be able to call the email variable from within AfterSignup code, finally i enbcountred a problem because i want to make a button which opens the AfterSignup window using the code :
AfterSignup.Show;
But the problem is that i am obliged to add the AfterSignup unit to the uses list of BeforeSignup and that is exactly what i can't do because i am alreadey using BeforeSignup to AfterSignup unit.
i receive an error saying, a reference of circular unit.
The easy solution would be to add unitA
in the uses
clause of the interface
section of unitB
and unitB
in the uses
clause of the implementation
section of unitA
The better solution would be to break the dependency for both (or at least one) units.
You can break the dependency by either
- moving all calls from
unitA
tounitB
intounitB
- adding a third, shared code unit, using both
units A & B
.
If your type declarations and variable declarations in the interface
section of a unit require classes or variables in another unit, then you should be adding the required unit to the uses
clause in the interface section.
However, if you only require the classes and variables in the implementation
part of your unit, in implementation code, then you should be adding the required unit only to the uses
clause in your implementation section.
If you have the unit already referenced in the interface section, you must not include it again in the implementation section.
If two units use each other only in the implementation section, there is no circular reference. You can also mix the uses, as long as two units don't use each other in the interface section (directly or indirectly), you won't have a circular reference.
So, based on your question, it seems like you should be using the units only in your implementation section, and there will be no circular reference.
来源:https://stackoverflow.com/questions/8592334/how-to-manage-circular-references-in-delphi-units