?
Solved

units...

Posted on 1998-09-23
6
Medium Priority
?
426 Views
Last Modified: 2010-07-27
I have used the menu function "Project->Add To Project" to add another unit (somename.pas). How do I access the functions of this new unit from my other units (especially the one with the form)?
0
Comment
Question by:lar_jens
6 Comments
 
LVL 1

Author Comment

by:lar_jens
ID: 1340725
Edited text of question
0
 
LVL 4

Accepted Solution

by:
itamar earned 150 total points
ID: 1340726
Hi lar_jens,

You must add the unit name to the Uses clause of the unit you want to "call" the functions.

You also (and it's better) to include a Uses clause just after the Implementation reserved word.

Example:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, YOURUNIT;

type
.


OR

.
implementation

{$R *.DFM}

uses YOURUNIT;

procedure TForm1.FormCreate(Sender: TObject);
.

IHTH,
Itamar

P.S.: Any doubts, place a comment before rejecting the answer.
0
 
LVL 1

Expert Comment

by:saam
ID: 1340727
Unit1 can use YOURUNIT by doing like itamar said.

tip.
if Unit1 uses YOURUNIT then YOURUNIT can not use Unit1.

(it would create a cyclical dependency. neither unit can be compiled without the other one being present.)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 2

Expert Comment

by:kjteng
ID: 1340728
Hi!
"if Unit1 uses YOURUNIT then YOURUNIT can not use Unit1." - This statement is only partly true.

If you need to use Unit1 in YourUnit then you should place the statement "uses Unit1;" in the implementation section of yourUnit.





0
 
LVL 10

Expert Comment

by:viktornet
ID: 1340729
Hi all!

kjteng is absolutly right!

//Viktor
0
 
LVL 1

Expert Comment

by:saam
ID: 1340730
hello kjteng!
yes, you are right. it actually works in delphi. i did not know. sorry.
(in turbo pascal it is not permitted that two units uses each other.)
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

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…
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…
Loops Section Overview
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

839 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