Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

units...

Posted on 1998-09-23
6
Medium Priority
?
425 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

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.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

618 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