Structuring a unit of supplemental procedures and functions in Delphi

The main form of an application was becoming overly large so I wanted to move some of the procs/functions to a supplemental unit.  I have done this and the application compiles and runs properly.  However, when I am in the main form and ctrl-click on the name of a procedure that is defined in the supplemental unit the cursor jumps to the top of the supplemental unit where the procedure is declared but does not move to the procedure code as it does if the proc is defined in the main form or another form.

I want to know if this is a limitation of the development environment or am I not properly structuring my unit of supplemental procs and functions?  (see code segments showing head of each file).

Thanks.
MAIN FORM - - - - - -
unit AppMain;
 
interface
uses
  . . . 
type
  TfrmMain = class(TForm)
  . . .
var
  frmMain: TfrmMain;
implementation
uses . . . AppGenProcs;
  . . .
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
SUPPLEMENTAL UNIT - - - - - - - -
unit AppGenProcs;
 
interface
 
uses
  Classes, SysUtils, Math;
 
procedure CaseStageChange(NewStage: Byte);
procedure CopyResultsGridToSourceFields;
 
implementation
 
uses AppMain;
 
procedure CaseStageChange(NewStage: Byte);
begin
  . . .
  . . .

Open in new window

ttheimerAsked:
Who is Participating?
 
8080_DiverConnect With a Mentor Commented:
Do you have all of your data access component on the Main FOrm?  If so, then you should move those and the associated functions/procedures for accessing the data to a DataModule.
Also, as pointed out above, you need to decouple the auxiliary units from the  main unit.  That is the whole idea of reusable code and modular/unit design.  You may have to slightly redesign some of you functions and procedures so that you pass them variables instead of having them directly snatch values from edit controls on the main form or having them use private/publix objects within the MainFrom's declaration.

If you have functions/procedures in your Supplemental Unit that do not receive parameters and, instead, directly access things in the main unit, you have what is called a closely coupled unit.  It is chained to the main unit.  If, on the other hand, you change it so that the various functions and procedures are passed parameters, you will probably find that you have less confusion over what is being used and how in the main unit.  
For instance, I have an AboutBox that I frequently use in my applications.  It is completely decoupled from any applications because it has its own public function (i.e. one that is not at all a part of the TWGAboutBox class) that activates the AboutBox and handles the setting up of the various captions, etc..  This lets me pass parameters (whether constants or variables) from my main app and have the AboutBox pop up with all its functionality.
 
0
 
JosephGloszCommented:
I've found that sometimes Delphi forgets the linkages there. Usually, the "ctrl-click" link can be restored when you do a full build (as opposed to a compile).   Well, at least for me that's true....  :)

0
 
Geert GConnect With a Mentor Oracle dbaCommented:
you should try to create helper units which do not need the mainform unit
by using parameters in the headers of the procs

this way you will not have circular references
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.