Forum > General

Reusable personal code libraries

(1/3) > >>

rwebb616:
I'm fairly new to Lazarus and learning.  I'm wondering how to best set up my own personal library of units that I can use for multiple applications for instance let's say I have some db routines that I write that would be the same for multiple applications.  What would be the best way to set that up? 

Rich

Martin_fr:
Create a new package (menu package -> new package).

Then in the package (the package window), in the toolbar "Add" > New File.

Now when you add the package to your project, you can add any of it's units to your "uses" clause.

You may find other methods on the internet, involving editing Path settings. Yes that is possible, but it can really quickly get you very strange errors.
Modifying the Path settings requires in depth knowledge.

Martin_fr:
Also, which ever way you go: Create yourself a repository (e.g. local git) of your units.

So if you edit them for project A, and you later compile project B and find your edits where wrong => you can still recover the old versions.

rwebb616:

--- Quote from: Martin_fr on May 11, 2021, 06:50:55 pm ---Create a new package (menu package -> new package).

Then in the package (the package window), in the toolbar "Add" > New File.

Now when you add the package to your project, you can add any of it's units to your "uses" clause.

You may find other methods on the internet, involving editing Path settings. Yes that is possible, but it can really quickly get you very strange errors.
Modifying the Path settings requires in depth knowledge.

--- End quote ---

That was a fast answer!  And it seems relatively simple. 

This forum is really amazing.  There are a handful (or three) of dedicated people that are always responding and to them I say THANK YOU!  Thank you for sharing your knowledge and your time to post examples and help us newcomers feel welcome and at the same time learn something!  I hope at some point that I can get good enough where I could actually answer some questions. 

rwebb616:

--- Quote from: Martin_fr on May 11, 2021, 06:55:17 pm ---Also, which ever way you go: Create yourself a repository (e.g. local git) of your units.

So if you edit them for project A, and you later compile project B and find your edits where wrong => you can still recover the old versions.

--- End quote ---

I'm still learning how to use Git.  Probably would be a good investment of time to get skilled in it's use.  I also have my own Atlassian BitBucket server which I guess could serve me well. 

Are there any IDE integrated git tools?  I used I think it was VS-Code which had git all integrated and you could make a commit? I think it's called... right from the editor. 

Rich

Navigation

[0] Message Index

[#] Next page

Go to full version