Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compile functions into a library 2

Status
Not open for further replies.

BobbaFet

Programmer
Feb 25, 2001
903
NL
Hey all,

I have a couple of functions and procedures which i use on various forms, which are basically also generally useful and i would like to compile them into an library so i could add it to the uses clause and have instantly access to them.




How can I do that?

Thanks in advance,

[bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
Hi there,

It's pretty easy - just make yourself a new unit, and copy all of your procedures and functions into it under the implementation section. Then make the interface section with declarations of your procedures and functions.

Save it into your $(Delphi)\Lib folder with a meaningful name, and then simply add it to the uses clause of any program you like.
 
Could you show me an example of that with a function and a procedure? Then I
know what it should look like.

Thanks in advance,

[bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
As Griffyn says, it is pretty easy:
Code:
unit Utility;

interface

procedure DoubleString ( var s: string );   

function AddTwoNumbers ( a, b: integer ): integer;

implementation

procedure DoubleString ( var s: string );   
begin
  s := s + s;
end;

function AddTwoNumbers ( a, b: integer ): integer;
begin
  result := a + b;
end;

end.

Andrew
 
Ghee, Bobbafet, Seeing previous answers from you, and now asking this... ;-)

NO
TonHu
 
Haha TonHu I guess that would be punischment for being
self-taught. I guess I learned the hard stuff first.

[bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
Hi BobbaFet,

Library can mean a lot of things.
If I was you, I would probably not use a
simple Unit, but I would rather use a package
( which can also be used as a plain DLL, ya know ).

This would give you many advantages, for example,
think of the possibility to use them as plain DLLs for
other languages, while exploiting power with Delphi.

It's not a case that experts can be loaded in plain
DLLs as well( DrBob docet ).

As to the type of package, I would suggest neither
design-time, nor run-time. This is one of those
very rare cases where the non-design and non-runtime
kind of package suits best.

Please remember anyway that if you want to follow this
path to be sure you're not going to modify it too
often, otherwise your Delphi programs may suffer :)

Cheers,

Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top