GreatCorn
GreatCorn

Reputation: 101

Call one procedure in another, that was declared before it

I have a situation:

procedure Compile();
begin
  //stuff
  CompileBatch();
end;

procedure CompileBatch();
begin
  //stuff
end;

But that obviously doesn't work, because identifier "CompileBatch" is not yet found in Compile. Are there any workarounds or do I have to rewrite all of the CompileBatch code in Compile? I'm using Free Pascal.

Upvotes: 1

Views: 83

Answers (1)

MartynA
MartynA

Reputation: 30715

You can do this by declaring your CompileBatch forward, like this:

procedure CompileBatch(); forward;

procedure Compile();
begin
  //stuff
  CompileBatch();
end;

procedure CompileBatch();
begin
  //stuff
end;

Upvotes: 5

Related Questions