Reputation: 53
I've got this:
procedure Welcome(user: string; accesslevel: integer);
begin
if accesslevel>= 10 then btCustomers.Text = 'Customer overview';
end;
Though, while the button exists on the form, btCustomers is declared an 'undeclared identifier'. What am I missing?
P.S. I am aware that this should be handled by the form OnCreate, but the Welcome procedure gets called from an external form.
Upvotes: 0
Views: 1308
Reputation: 613562
You could to pass a reference to the form so that the button can in turn be referenced.
procedure Welcome(form: TMyForm; user: string; accesslevel: integer);
begin
if accesslevel>= 10 then form.btCustomers.Text = 'Customer overview';
end;
However, any time you have a global scope function that takes as its first parameter a reference to an object, you have a candidate for a method of that object. So, add a method to TMyForm
.
procedure TMyForm.Welcome(user: string; accesslevel: integer);
begin
if accesslevel>= 10 then btCustomers.Text = 'Customer overview';
end;
And call it like this:
MyForm.Welcome(user, accesslevel);
Upvotes: 5