[DUG] Uses
John Bird
johnkbird at paradise.net.nz
Tue Apr 3 15:51:32 NZST 2007
I have a standard component thingy from which I want to be able to call
routines that are specific to one project.
My aim is to centralise some complex functions like data editing or printing
as much as possible in one powerful unit, but still have the shared unit
able to call functionality specific to this project.
I presume the best way to do this is to vary the uses clause for the
project, using the same function names that exist in different units.
However the standard component thingy has to have a fixed unit name in its
"uses" clause.
Say the component thingy is called StandardEdit, and calls some functions
called
GeneralLoadData and GeneralSaveData
The StandardEdit unit would have
"Uses GeneralFunctions" in its uses clause.
I could have several units called GeneralFunctions (in various folders) with
functions called
GeneralLoadData and GeneralSaveData in each of them,
One could be in a folder called DummyGeneral, and each function just does
nothing. This would be used in cases where the StandardEdit is being used
(but no special functionality is needed in these functions) just to satisfy
the linker.
And others specific to the project could be in the project folder for a
specific program, with code in each function specific to that project - eg
for project Fred1
"Uses GeneralFunctions in "\src\Fred1\GeneralFunctions.pas"
Which one gets linked in to a particular program depends on the DPR which
defines which SharedFunctions unit is actually included in this project.
Question - is this the best way to call specific tailored routines from a
standard shared unit, or is there another better way I have missed?
John
More information about the Delphi
mailing list