I get the "Undeclared identifier" in a pprocedure I created called submit.
procedure submit;
begin
if ebMain.Text='exit' then
fmMain.Close;
end;
Really simple. The compiler tells me ebMain is undeclared. I ca fix this by putting "fmMain." in front of it but I never had to do this in delphi 7.The edit box(ebMain) is on the main form(fmMain). The procedure header is placed just under the "uses". What's wrong?
submit()
is not a member of your TfrmMain
class, so it does not know what ebMain
is. You need to either:
1) make submit()
be a member of your form's class (which you should do anyway because all it is doing is accessing members of TfrmMain
):
procedure TfrmMain.submit;
begin
if ebMain.Text='exit' then
Close;
end;
procedure submit;
begin
frmMain.submit;
end;
2) prefix ebMain
with the form's global frmMain
variable (like you are already doing for Close()
):
procedure submit;
begin
if frmMain.ebMain.Text='exit' then
fmMain.Close;
end;
Yes, you would have had to do this in every version of Delphi, including D7.