[ACCEPTED]-How to run procedure from another unit?-delphi-units
Accepted answer
You need to put the procedure's signature 3 in your interface, like so:
unit main;
interface
procedure Discard();
implementation
procedure Discard();
begin
//do whatever
end;
Other units can 2 only "see" whatever's listed in the interface 1 section.
In unit "Main" you declare Discard in the 4 "interface" section:
unit Main;
interface
uses ...
procedure Discard (...); // only the declaration, not the entire procedure
implementation
... // code
Now in unit "Engine" you 3 add "Main" to the "uses" section.
uses Main, ...
Thats it, you 2 can call Discard(...)
now. If there are more than one 1 Discard()
you can explicitely call this Discard()
by using Main.Discard()
.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.