Board index » delphi » Problem combining Units

Problem combining Units

I'm not yet fluent in Object Pascal. So maybe this is very obvious.
My objective here was to split the code over several Units
rather than have one huge program.

But now I keep getting a {*word*193} error message which I just
can't get rid of: **Unsatisfied forward or external declaration
TDataModule1.ConvertToHTML** The help on this one isn't
helpful at all. It advises me ao.: <quote>you have to supply the
implementation (the body of the procedure or function) in the
implementation section</quote>. Something I already did.

I've tried several things but it keeps coming up. Maybe you
see what I'm doing wrong here.

Thanks,

Hans van Mourik              Netherlands Historical Data Archive
mou...@rullet.leidenuniv.nl  http://www.leidenuniv.nl/nhda/

Follows code:
----8<-----------------
unit SQLUnit;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  DB, DBTables; // just about everything, including the kitchen sink

type
  TDataModule1 = class(TDataModule)
    Query1: TQuery;
    procedure ConvertToHTML(TableRef: TQuery; Var Result: TextFile);
    // Here it {*word*88}s: **Unsatisfied forward or external declaration blah blah.**
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  DataModule1: TDataModule1;

implementation

{$R *.DFM}

procedure ConvertToHTML(TableRef: TQuery; Var Result: TextFile);
const
   // consts here

var
  n, max: integer;
  FType: array [0 .. 100] of string;

Begin
writeln (Result, '<table border>' );
write (Result, '<tr>' );
   max := TableRef.FieldCount -1;
   // do lotsa stuff
writeln (Result, '</table>' );
End;

end.

 

Re:Problem combining Units


Zie aanpassing in de code

Met viendelijke groet Ed Lagerburg

Hans van Mourik <mou...@rullet.leidenuniv.nl> schreef in artikel
<5f1rbj$...@highway.leidenuniv.nl>...

Quote
> I'm not yet fluent in Object Pascal. So maybe this is very obvious.
> My objective here was to split the code over several Units
> rather than have one huge program.

> But now I keep getting a {*word*193} error message which I just
> can't get rid of: **Unsatisfied forward or external declaration
> TDataModule1.ConvertToHTML** The help on this one isn't
> helpful at all. It advises me ao.: <quote>you have to supply the
> implementation (the body of the procedure or function) in the
> implementation section</quote>. Something I already did.

> I've tried several things but it keeps coming up. Maybe you
> see what I'm doing wrong here.

> Thanks,

> Hans van Mourik              Netherlands Historical Data Archive
> mou...@rullet.leidenuniv.nl  http://www.leidenuniv.nl/nhda/

> Follows code:
> ----8<-----------------
> unit SQLUnit;

> interface

> uses
>   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,
>   DB, DBTables; // just about everything, including the kitchen sink

> type
>   TDataModule1 = class(TDataModule)
>     Query1: TQuery;
>     procedure ConvertToHTML(TableRef: TQuery; Var Result: TextFile);
>     // Here it {*word*88}s: **Unsatisfied forward or external declaration blah
blah.**
>   private
>     { Private declarations }
>   public
>     { Public declarations }
>   end;

> var
>   DataModule1: TDataModule1;

> implementation

> {$R *.DFM}

                   dit ben je vergeten          

- Show quoted text -

Quote
>                 VVVVVVVVV
> procedure TDataModule1.ConvertToHTML(TableRef: TQuery; Var Result:
TextFile);
> const
>    // consts here

> var
>   n, max: integer;
>   FType: array [0 .. 100] of string;

> Begin
> writeln (Result, '<table border>' );
> write (Result, '<tr>' );
>    max := TableRef.FieldCount -1;
>    // do lotsa stuff
> writeln (Result, '</table>' );
> End;

> end.

Re:Problem combining Units


Quote
>   mou...@rullet.leidenuniv.nl (Hans van Mourik) writes:
>  I'm not yet fluent in Object Pascal. So maybe this is very obvious.
>  My objective here was to split the code over several Units
>  rather than have one huge program.

I have not studied your problem in detail but generally you need to declare your procedures and functions in the interface section.
Then you have to add the unit containing these procedures and functions to the uses clause of the unit that needs to call them.

To get details on this look in the online help.

johan

Re:Problem combining Units


Quote
Hans van Mourik wrote:

> But now I keep getting a {*word*193} error message which I just
> can't get rid of: **Unsatisfied forward or external declaration
> TDataModule1.ConvertToHTML** The help on this one isn't
> helpful at all. It advises me ao.: <quote>you have to supply the
> implementation (the body of the procedure or function) in the
> implementation section</quote>. Something I already did.

Your code was as follows:

Quote
> type
>   TDataModule1 = class(TDataModule)
>     Query1: TQuery;
>     procedure ConvertToHTML(TableRef: TQuery; Var Result: TextFile);
>     // Here it {*word*88}s: **Unsatisfied forward or external declaration blah blah.**
>   private
>     { Private declarations }
>   public
>     { Public declarations }
>   end;

> var
>   DataModule1: TDataModule1;

> implementation

> {$R *.DFM}

> procedure ConvertToHTML(TableRef: TQuery; Var Result: TextFile);
> const
>    // consts here

> var
>   n, max: integer;
>   FType: array [0 .. 100] of string;

> Begin
> writeln (Result, '<table border>' );
> write (Result, '<tr>' );
>    max := TableRef.FieldCount -1;
>    // do lotsa stuff
> writeln (Result, '</table>' );
> End;

> end.

Our suggestion:

Try to change the line "procedure ConvertToHTML ..." into

procedure TDataModule1.ConvertToHTML(TableRef: TQuery; Var Result:
TextFile);

in the implementation section.

Other Threads