Re: reusing routines
- From: "Maarten Wiltink" <maarten@xxxxxxxxxxxxxxxxxx>
- Date: Wed, 18 May 2005 09:12:39 +0200
"Anthony" <ajh@xxxxxxxxxxxx> wrote in message
news:428ae539$1@xxxxxxxxxxxxxxxxxxxx
> How can I write a unit that contains varibles, strings, routines etc
> that I can reuse. if I have a unit that contains those things and
> delare it in my uses clause I should be able to address those routines
> from any project. very good in theory, but how do I use then from my
> project
>
> eg: if I have a routine called save-all
>
> how can I call it from within another unit, (say the mani unit),
Assume units Main and Library, you currently being in Main.
You can use anything declared in Library's interface section if that
unit is mentioned in a preceding uses clause. There are two of these,
one at the start of the interface section and one at the implementation
section. If you need one that isn't there, you can just add it.
If you want to be explicit, you can qualify an identifier with a unit
name. If both Main and Library declare a type TIndex, you can force the
issue by writing Library.TIndex. Plain TIndex would default to the one
in the current scope, the Main unit. If Main _didn't_ declare such a
type, the compiler would start looking for it in used units. This is
a source both of bugs and flexibility. Make your own choices and don't
be afraid to make different choices at different times. As a rule of
thumb, try to avoid the issue by using different names across units.
Any identifiers declared in the interface section of Library are
visible from other units. Any identifiers declared in the implementation
section are not. Private and protected members of classes add their own,
stricter, visibility rules.
Groetjes,
Maarten Wiltink
.
- References:
- reusing routines
- From: Anthony
- reusing routines
- Prev by Date: reusing routines
- Next by Date: Re: Help re Help
- Previous by thread: reusing routines
- Next by thread: Re: reusing routines
- Index(es):
Relevant Pages
|