Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

I am having problems with 'uses'

Posted on 2011-09-12
7
Medium Priority
?
517 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 400 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

783 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