Solved

units...

Posted on 1998-09-23
6
419 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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