Solved

units...

Posted on 1998-09-23
6
416 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 50 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

15 Experts available now in Live!

Get 1:1 Help Now