Board index » delphi » Newbie: "Unsatisfied forward or external declaration"

Newbie: "Unsatisfied forward or external declaration"

As a newbie I've been wringing my brain over this errormessage from the
compiler.

There is something wrong with the declaration of the "Function TiMin",
and I just can't
figure out what's wrong.  I've taken out the type declarations from the
code.

Is there anyone who can help me?

Torstein Tysklind
torstein.tyskl...@home.se

unit tidbild;

interface

uses
  SysUtils, Windows, Messages, Classes, Graphics, Controls,
  StdCtrls, Forms, DBCtrls, DB, Mask, DBTables, ExtCtrls, Buttons;

type
  TForm2 = class(TForm)

    Function TiMin (Tid:String) : Integer;
    procedure FormCreate(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);

  private
    { private declarations }
  public
    { public declarations }

  end;

var
  Form2: TForm2;

implementation

{$R *.DFM}

Function TiMin (Tid:String) : Integer;
begin
     Result := StrToInt(Tid[1]+Tid[2])*60 + StrToInt(Tid[4]+Tid[5]);
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
  Table1.Open;
end;

procedure TForm2.BitBtn1Click(Sender: TObject);
begin
application.terminate
end;

end.

 

Re:Newbie: "Unsatisfied forward or external declaration"


Torstein,
  The problem is a very simple one. You have the function there alright, but
you have not specified that it belongs to the form's class... change the
line that reads "Function TiMin (Tid:String) : Integer;"  to read
"FORM2.Function TiMin (Tid:String) : Integer;" and you will be fine.
                          Good luck!!
                                   Dave
                                       http://www.erols.com/dparsons

Quote
Torstein Tysklind wrote in message <350C2B2B.209CF...@home.se>...
>As a newbie I've been wringing my brain over this errormessage from the
>compiler.

>There is something wrong with the declaration of the "Function TiMin",
>and I just can't
>figure out what's wrong.  I've taken out the type declarations from the
>code.

>Is there anyone who can help me?

>Torstein Tysklind
>torstein.tyskl...@home.se

>unit tidbild;

>interface

>uses
>  SysUtils, Windows, Messages, Classes, Graphics, Controls,
>  StdCtrls, Forms, DBCtrls, DB, Mask, DBTables, ExtCtrls, Buttons;

>type
>  TForm2 = class(TForm)

>    Function TiMin (Tid:String) : Integer;
>    procedure FormCreate(Sender: TObject);
>    procedure BitBtn1Click(Sender: TObject);

>  private
>    { private declarations }
>  public
>    { public declarations }

>  end;

>var
>  Form2: TForm2;

>implementation

>{$R *.DFM}

>Function TiMin (Tid:String) : Integer;
>begin
>     Result := StrToInt(Tid[1]+Tid[2])*60 + StrToInt(Tid[4]+Tid[5]);
>end;

>procedure TForm2.FormCreate(Sender: TObject);
>begin
>  Table1.Open;
>end;

>procedure TForm2.BitBtn1Click(Sender: TObject);
>begin
>application.terminate
>end;

>end.

Re:Newbie: "Unsatisfied forward or external declaration"


In article <350C2B2B.209CF...@home.se>,

Quote
  torstein.tyskl...@home.se wrote:

[...]
> type
>   TForm2 = class(TForm)

>     Function TiMin (Tid:String) : Integer;

    This declares TiMin as a _method_ of TForm2, not as
an ordinary stand-alone function.

[...]

Quote
>   end;

> var
>   Form2: TForm2;

> implementation

> {$R *.DFM}

> Function TiMin (Tid:String) : Integer;
> begin
>      Result := StrToInt(Tid[1]+Tid[2])*60 + StrToInt(Tid[4]+Tid[5]);
> end;

      This is the implementation of a stand-alone function. Delphi
doesn't know that this is what you meant as the implementation of
TForm2.TiMin - it's still looking for the implementation of that
method. So change this to

Function TForm2.TiMin (Tid:String) : Integer;
begin
     Result := StrToInt(Tid[1]+Tid[2])*60 + StrToInt(Tid[4]+Tid[5]);
end;

Quote
> procedure TForm2.FormCreate(Sender: TObject);
> begin
>   Table1.Open;
> end;

        Hey, look: this is a hint what was wrong! In the interface
it said "FormCreate", not "TForm2.FormCreate", but here it says
TForm2.FormCreate. You can actually learn a lot about how these
things work by starting a blank project and studying the code.

David C. Ullrich

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading

Re:Newbie: "Unsatisfied forward or external declaration"


No problem here.....

Quote
>    Function TiMin (Tid:String) : Integer;

Here you must declare the function with the class type definition to which
it belongs...

i.e. function TForm2.TiMin(Tid:String):integer;
                    **********

rather than

Quote
>Function TiMin (Tid:String) : Integer;

JC

Re:Newbie: "Unsatisfied forward or external declaration"


You must declare your functions and procedures in the implementation section
with the class name : i.e

Function TForm2.TiMin(Tid:String):integer;
                *********
JC

Other Threads