emurad
emurad

Reputation: 3558

How to call a function stored in a Unit?

I created a new unit because there are functions that I need to call from all forms and I placed the unit name in the uses list.

I don't get any error at design time but when I try to start the application I get [DCC Error] UnitForm1.pas(64): E2003 Undeclared identifier: 'TaskBarHeight'

Please help. Thanks.

Upvotes: 1

Views: 2780

Answers (1)

Andreas Rejbrand
Andreas Rejbrand

Reputation: 108938

Is TaskBarHeight declared in the interface section of the unit?

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.

In the above example, only the function HighBeep is visible in other units. Also, only the constant alpha is. The function sum is also visible.

Upvotes: 4

Related Questions