-3

私の問題は次のように見えます.2つのプロシージャがあり、それらは互いに呼び出しますが、これによりオーバーフローが発生する可能性があります. プロシージャにジャンプする方法 - asm jmp が呼び出されないように? 2 つの異なるプロシージャ間で GoTo を使用できないため、ラベルを使用したくありません。そして、プロシージャーの呼び出しに続くコードを実行したくありません。ところで、私はFPCを使用しています。

unit sample;
interface

procedure procone;
procedure proctwo;

implementation

procedure procone;
begin
writeln('Something');
proctwo;
writeln('After proctwo'); //don't execute this!
end;

procedure proctwo;
begin
writeln('Something else');
procone;
writeln('After one still in two'); //don't execute this either
end;

end.
4

1 に答える 1

1

関数パラメーターを使用して再帰を示す必要があるため、関数は関連する関数によって呼び出されていることを認識できます。例えば:

unit sample;

interface

procedure procone;
procedure proctwo;

implementation

procedure procone(const infunction : boolean);
begin
  writeln('Something');
  if infunction then exit;
  proctwo(true);
  writeln('After proctwo'); //don't execute this!
end;

procedure proctwo(const infunction : boolean);
begin
  writeln('Something else');
  if infunction then exit;
  procone(true);
  writeln('After one still in two'); //don't execute this either
end;

procedure usagesample;
begin
  writeln('usage sample');
  writeln;
  writeln('running procone');
  procone(false);
  writeln;
  writeln('running proctwo');
  proctwo(false);
end;

end.

usagesample呼び出されると、次のように生成されます。

usage sample

running procone
Something
Something else
After proctwo

running proctwo
Something else
Something
After one still in two
于 2012-07-18T01:38:19.450 に答える