Solved

I am having problems with 'uses'

Posted on 2011-09-12
7
497 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

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…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses
Course of the Month10 days, 9 hours left to enroll

632 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