Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using code in other units

Status
Not open for further replies.

cimnik2999

Programmer
Oct 25, 2003
12
CA
Hey. im a new to delphi, and i would like to know how i can include code in a unit that i wrote in another unit in the project. I tried adding the unit's name under uses, but it doesn;t see to work
 
Hi!
I´m also rather newbie to Delphi...

Have you tried to put the unitname under

implementation
uses yourUnit;


Regards
TompaD
 
yeah and it says it can find the functions still. So i need to put in some sort of function declaration?
 
have you also added the unit to the project?

like in:

Code:
program MyProgram;

uses
  Forms,
  unit1 in 'unit1.pas' {Form1},
  yourUtils in 'yourUtils.pas',
  ...
{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
 
i'm not sure whether it's correct or not.. cos i'm newbie too...

how bout if u declare an object to access other units ??

like the following example, i need to use the TdmBug units in current form/unit.. so i create an object of type (self)so i can access other form/units..


procedure TfrmClients.FormCreate(Sender: TObject);
begin
FdmBug := TdmBug.Create(Self);
DataSource1.DataSet := FdmBug.ClientDataSet1;
end;

P/S: ClientDataset1 is on the TdmBug units.. so i simply use FdmBug(temp object that i'd create) to call it...
 
It may be that Delphi cannot see the file.

If the file is not on a path that delphi knows about (in your library paths for example), you will need to add the path (Tools-Enviroment menu, Library Tab) or manually add the unit to your project (Project Manager-Add).

Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
well, it doesn't generate an error including the unit in either the unit i want it in or in the project header. the exe compiles perfectly except it doen't recognise the FUNCTIONS. however, putting a dot after the units name does produce the list of variables in it...

thanks for helping
 
Are the functions public or private?

Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
the functions, procedures and variables you want to use from that unit must be of public type in order to be used from your 'base' unit.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top