?
Solved

units...

Posted on 1998-09-23
6
Medium Priority
?
423 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
[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
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

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.

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

801 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