Solved

I am having problems with 'uses'

Posted on 2011-09-12
7
490 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

734 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