で、Checkという関数は関数内関数で書いてみる。
駒の隣と、その後では別けなきゃいけないから、さらに関数内関数を呼ぼう。

function okeruka(const BAN:TBAN;K:TKOMA;x,y:Integer):boolean;
function Check(dx,dy,x,y:Integer):boolean;
function Check1:boolean;
begin
x:=x+dx;
y:=y+dy;
Result:= x >=LOW(BAN); if not Result then exit;
Result:= x <=HIGH(BAN); if not Result then exit;
Result:= y >=LOW(BAN[x]); if not Result then exit;
Result:= y <=HIGH(BAN[x]); if not Result then exit;
Result:= BAN[x,y]=AiteNoKoma(K) ;
end;
function Check2:boolean;
begin
x:=x+dx;
y:=y+dy;
Result:= x >=LOW(BAN); if not Result then exit;
Result:= x <=HIGH(BAN); if not Result then exit;
Result:= y >=LOW(BAN[x]); if not Result then exit;
Result:= y <=HIGH(BAN[x]); if not Result then exit;
if BAN[x,y]=AiteNoKoma(K) then Result:= Check2;
result:= BAN[x,y]=K;
end;
begin
Result:=Check1; if not Result then exit;
Result:=Check2;
end;