Solved

I am having problems with 'uses'

Posted on 2011-09-12
7
472 Views
Last Modified: 2012-08-13
Hello,

There is a pascal unit that I would like to access methods from so I place a copy of it in my project folder and put the name of the file excluding the '.pas' inside the uses clause.

Now it is saying

File not found: libZplay.dcu'.

Now as far as I remember to fix that kind of problem, I always had to add the current project folder to the library path and I can't remember that well but I am kinda sure that adding that to the library path fixed it.

Questions:

1) Do I  always have to add it to the library path every time I want to access types, function or procedures or a class from a unit?

2) Why can I not just put it in my local project folder? Is that bad practise?

Any advice
0
Comment
Question by:AivsCoder
  • 4
  • 3
7 Comments
 

Author Comment

by:AivsCoder
ID: 36521738
oh by the way

the file is called

libZPlay.pas
0
 

Author Comment

by:AivsCoder
ID: 36521741
oh I just realised that I got different results when I saved the project file and then compiled it.
now I do not have that problem?

What just happened?

Ben
0
 
LVL 25

Expert Comment

by:epasquier
ID: 36521791
By saving it, you effectively told the project its base directory.

Until you save it first, all file loading based on relative directories will be sketchy at best

If you have units that you will use on many projects, like this, you put them in a \Unit directory that you will add in the default search path for all projects, so you don't have to set it for all new project

and yes it is bad practice to copy/move around units in each project directory : what if you add something for one project, like a great improvement in functionality or performance ? You will have to copy it back to all projects that use it to make those benefit of the changes.

So, keep all units in ONE place only, or when the units comes in a big library package, put those in \Units\GreatLib that you will add also in the search path.
Or whatever organization that suits your needs, but these are good guidelines
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 25

Expert Comment

by:epasquier
ID: 36521814
So, keep all units in ONE place only
Of course, I mean all TOOLS unit, not the ones specific to a project

With 15 years of Delphi in my back, I now have 135 units of my own that I constantly reuse on all projects. And I'm glad to spend days to improve just a bit of feature because I know that all my projects will get something of it.
And when I start a new one, I have all the framework setup, and I'm ready to work in no time.

Same goes for the components I install, they are nicely regrouped in a \Comps directory (never let one go in the default C:\Program Files\SomeComponentPack that some Setup.exe will use).
When I want to duplicate my Delphi environment, I simply copy a \Delphi directory, and it will then get
\Delphi\Comps
\Delphi\Units
\Delphi\Projects
\Delphi\Experts
\Delphi\Tools

Open in new window

etc... got the picture ?
0
 

Author Comment

by:AivsCoder
ID: 36526727
Just out of curiousity, where do I go to add a path to the default search path?
Is that the library path or browsing path or neither?

One thing I didn't understand is duplicating a Delphi environment.
I guess your refering to duplicating your Delphi environment for another pc with Delphi installed?

so in the comps folder, you would have the .pas, and the .dcu files?
Anything related to a component would go in there.
Might you have nested folders in there for each different component housing the .pas and .dcu?

I like your approach, it sounds very professional and well organised.
Thanks

0
 
LVL 25

Accepted Solution

by:
epasquier earned 100 total points
ID: 36528480
I guess your refering to duplicating your Delphi environment for another pc with Delphi installed?
Precisely. To be more exact, it's on the same PC but one environment is on a Virtual machine (XP 32 bits) vs Seven x64 for the host

so in the comps folder, you would have the .pas, and the .dcu files?
Yes, and whatever comes with the component or is produced by compilation of those (when I have source)

About Path : yes, that is "Search Path" in project options. Delphi XE can manage default values for all new project or even old projects (you only define in project search path whatever specific folder, and it will look automatically in the global parameters), it's in
 Tools -> Options , then
Environment Options -> Delphi Options -> Library ,
[ Library Path ] => that is where you add all the paths to \Delphi\Units & \Delphi\Comps\SomeComp\Src , \Delphi\Comps\AnotherComp\Lib etc...
0
 

Author Closing Comment

by:AivsCoder
ID: 36547647
Appreciate your help. Thanku, Ben
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now