如何从另一个单元运行程序? [英] How to run procedure from another unit?
本文介绍了如何从另一个单元运行程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这样的n00b问题,但我仍然无法弄清楚.我的单元main
中包含过程Discard()
.现在,我有另一个单元engine
,我想从中运行单元main
的过程Discard()
.我在engine.pas
的uses
部分有主菜单.我试图用main.Discard()
调用过程,但是效果不好.我在做什么错了?
Well this kind of n00b question but I still can't figure it out. I have unit main
with procedure Discard()
in it. Now I have another unit engine
and I want to run from it procedure Discard()
of unit main
. I have main in uses
section of engine.pas
. I tried to call procedure with main.Discard()
but no good. What am I doing wrong?
推荐答案
您需要将过程的签名放在界面中,如下所示:
You need to put the procedure's signature in your interface, like so:
unit main;
interface
procedure Discard();
implementation
procedure Discard();
begin
//do whatever
end;
其他单元只能查看"界面部分列出的内容.
Other units can only "see" whatever's listed in the interface section.
这篇关于如何从另一个单元运行程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文