Re: reusing routines



"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


.



Relevant Pages

  • Re: Public Variables
    ... If you wanted to really follow the OOP paradigm, ... > Are you stating that I should ALWAYS declare ALL variables as private? ... > My object is not to learn programming style as I only wrote this one ... >>> The program consists of 2 forms, and about 12 routines I wrote. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Public Variables
    ... Are you stating that I should ALWAYS declare ALL variables as private? ... when every other proceedure needs to know the new value. ... >> The program consists of 2 forms, and about 12 routines I wrote. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Template method pattern in Java ???
    ... > only caveats being that contracts may refer to other routines and it ... Perhaps we need two kinds of interface: ... > also allows for the inheritance of non-purely abstract classes. ... This is different in Java ...
    (comp.object)
  • Re: Template method pattern in Java ???
    ... > only caveats being that contracts may refer to other routines and it ... Perhaps we need two kinds of interface: ... > also allows for the inheritance of non-purely abstract classes. ... This is different in Java ...
    (comp.lang.java.programmer)
  • Re: Template method pattern in Java ???
    ... > only caveats being that contracts may refer to other routines and it ... Perhaps we need two kinds of interface: ... > also allows for the inheritance of non-purely abstract classes. ... This is different in Java ...
    (comp.lang.java.help)