2
votes

I have two DWScript unit files:

unit unit1;                    | unit unit2;
                               | 
interface                      | interface
                               | 
procedure Proc1exec;           | procedure Proc2exec;
procedure Proc1;               | procedure Proc2;
                               | 
implementation                 | implementation
                               | 
uses unit2;                    | uses unit1;
                               | 
procedure Proc1exec;           | procedure Proc2exec;
begin                          | begin
  unit2.Proc2;                 |   unit1.Proc1;
end;                           | end;
                               | 
procedure Proc1;               | procedure Proc2;
begin                          | begin  
end;                           | end;

During compilation of unit1 I get

ECompileError with message 'Unknown Name "unit1.Proc1"'

with the following text in IdwsProgram.Msgs.AsInfo:

Syntax Error: Unknown name "unit1.Proc1" [line: 14, column: 9, file: unit2]

Kindly explain how could I compile such circular referenced units.

Edit: In order to make the discussion closer to my requirements, I'll reformulate the question. Why DWScript does not allow me to compile these two units?

2

2 Answers

0
votes

One solution is to put everything in one unit.

Another one is:

unit shared;

interface

procedure Proc1exec;
procedure Proc2exec;

implementation

uses unit1, unit2;

procedure Proc1exec;
begin
  unit1.proc1;
end;

procedure Proc2exec;
begin
  unit2.proc2;
end;

and

unit unit1;

interface

procedure Proc1;

implementation

procedure Proc1;
begin
  // do something useful
end;

end.

And something similar for unit2.

Now your code only has to include:

program Test;

uses
  unit1, unit2, shared;

begin
  Proc1exec;
  Proc2exec;
end.
0
votes

At the end I switched to PaxCompiler. It handles the units from original post without issues. It is also easy to use and covers my requirements completely.