Solved

Call Procedure From A Separate Unit

Posted on 2002-04-30
7
331 Views
Last Modified: 2010-04-04
I have two units.  Unit1 holds a procedure called task.
How can I call that procedure from unit2?
0
Comment
Question by:brettawv
7 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6980711
somewhere in unit2

implementation
uses unit1;  //* thats the goal

procedure whatever;
begin
  callproc_in unit1;
end;

meikl ;-)
0
 

Author Comment

by:brettawv
ID: 6980806
Here's what I have.

Unit1:

procedure FillCharCode;
var
  C: Integer;
  F: Integer;
Begin
  F:= 13;
  For C:= 0 to 19 do
    Begin
      With Form1.StringAlignGrid1 Do
        Begin
          Cells[C,0]:= IntToStr(C + 1);
          Cells[C,1]:= DataModule1.AdsQuery10.FieldByName
                       (DataModule1.AdsQuery10.FieldDefs
                       [F].name).AsString;
          F:= F + 1;
        End;
    End;
End;


Unit2:

implementation

uses unit1, dmod1;

{$R *.DFM}

Procedure DoSomething;
Begin
  FillCharCode;
End;

It tells me undeclared identifier 'FillCharCode'.
What am I doing wrong?

Thanks

0
 
LVL 5

Accepted Solution

by:
alanwhincup earned 100 total points
ID: 6981023
Stick this in between interface and implementation in Unit1 and it should work.

procedure FillCharCode;

Cheers,

Alan
0
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.

 
LVL 3

Expert Comment

by:tongalite
ID: 6981030
Hi,
Try adding the variables.
t.
0
 
LVL 5

Expert Comment

by:alanwhincup
ID: 6981032
Unit 1 should then look like:

Unit1;

...

interface

...

procedure FillCharCode;

implementation

...

procedure FillCharCode;
var
 C: Integer;
 F: Integer;
Begin
 F:= 13;
 For C:= 0 to 19 do
   Begin
     With Form1.StringAlignGrid1 Do
       Begin
         Cells[C,0]:= IntToStr(C + 1);
         Cells[C,1]:= DataModule1.AdsQuery10.FieldByName
                      (DataModule1.AdsQuery10.FieldDefs
                      [F].name).AsString;
         F:= F + 1;
       End;
   End;
End;

...

end.
0
 

Author Comment

by:brettawv
ID: 6981056
Thanks, I really appreciate it.
0
 
LVL 4

Expert Comment

by:SurferJoe
ID: 6981069
alanwhincup is correct, depending on the desired "global" scope of the procedure, You can also do this and declare the procedure normally.


Procedure TForm2.DoSomething;
Begin
 Form1.FillCharCode;
End;

Regards,

Greg
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
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…

746 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

12 Experts available now in Live!

Get 1:1 Help Now