Solved

I am having problems with 'uses'

Posted on 2011-09-12
7
476 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
loading dll from external path 1 213
delphi prevent click fast 2 192
Internet Explorer View Settings Question 15 107
Create a path if not exists 7 69
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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

23 Experts available now in Live!

Get 1:1 Help Now