如何调用存储在Unit中的函数?

时间:2010-12-10 23:59:50

标签: delphi pascal

我创建了一个新单元,因为我需要从所有表单中调用函数,并将单元名称放在 uses 列表中。

我在设计时没有收到任何错误,但是当我尝试启动应用程序时,我得到[DCC错误] UnitForm1.pas(64):E2003未声明的标识符:'TaskBarHeight'

请帮忙。感谢。

1 个答案:

答案 0 :(得分:4)

是否在单位的TaskBarHeight部分宣布了interface

unit Unit4;

interface

uses Windows;

procedure HighBeep;

function Sum(const A, B: integer): integer;

const
  alpha = 10;

implementation

const
  beta = 20;

procedure HighBeep;
begin
  Beep(800, 500);
end;

procedure LowBeep;
begin
  Beep(400, 500);
end;

function Sum(const A, B: integer): integer;
begin
  result := A + B;
end;

end.

在上面的示例中,只有函数HighBeep在其他单位中可见。此外,只有常量alpha。功能sum也可见。