Board index » delphi » Procedure does not work

Procedure does not work

How come I get the error message: Error 59: Undefined
forward:(TMainform.ShowOwners) and points to the end. of the code. I
declared the procedure ShowOwners on top of the source code in the type
section under public as: procedure ShowOwners;

procedure ShowOwners;
var
   I: Integer;
   FoundIt: Boolean;
begin
   FoundIt := False;
   with MainForm do
      for I := MDIChildCount-1 downto 0 do
         if MDIChildren[I].Caption = 'Owners' then
            FoundIt := True;
   if FoundIt = False then
      Application.CreateForm(TfrmOwners, frmOwners);
   frmOwners.Show;
   frmOwners.WindowState := wsMaximized;
end;

--
Thomas Jaeger
czars...@ix.netcom.com
http://www.execpc.com/~czarsoft

 

Re:Procedure does not work


Quote
"Thomas Jaeger" <czars...@ix.netcom.com> writes:
>How come I get the error message: Error 59: Undefined
>forward:(TMainform.ShowOwners) and points to the end. of the code. I
>declared the procedure ShowOwners on top of the source code in the type
>section under public as: procedure ShowOwners;

Because you need to change the first line to:

procedure TMainForm.ShowOwners;
var
{
  etc, etc..

Quote
}

Mike Lastort
Software Engineer

Re:Procedure does not work


Quote
Thomas Jaeger wrote:

> How come I get the error message: Error 59: Undefined
> forward:(TMainform.ShowOwners) and points to the end. of the code. I
> declared the procedure ShowOwners on top of the source code in the type
> section under public as: procedure ShowOwners;

        Does this mean it's declared as a method of the form
(ie it's part of the definition of TForm1)? If so you could try
changing

Quote
> procedure ShowOwners;

to

procedure TForm1.ShowOwners;

.
--
David Ullrich
Sig file accidentally deleted - sorry.

Re:Procedure does not work


I belive that you would have to name the procedure

Procedure Form1.ShowOwners;

When you declare a procedure or function under the type declaration for
the form where all the other procedures are declared, you have to
preface the procedure name with the name of your main form.  Hope this
helps.

procedure ShowOwners;
var
   I: Integer;
   FoundIt: Boolean;
begin
   FoundIt := False;
   with MainForm do
      for I := MDIChildCount-1 downto 0 do
         if MDIChildren[I].Caption = 'Owners' then
            FoundIt := True;
   if FoundIt = False then
      Application.CreateForm(TfrmOwners, frmOwners);
   frmOwners.Show;
   frmOwners.WindowState := wsMaximized;
end;

Re:Procedure does not work


Quote
"Thomas Jaeger" <czars...@ix.netcom.com> wrote:
>How come I get the error message: Error 59: Undefined
>forward:(TMainform.ShowOwners) and points to the end. of the code. I
>declared the procedure ShowOwners on top of the source code in the type
>section under public as: procedure ShowOwners;
>procedure ShowOwners;

declare it with this line:
procedure TMainform.ShowOwners;

hope this helps
Meik Weber
m.we...@public.ndh.com or
100744.3...@compuserve.com

Other Threads