コードを検証する
JvInterpreterProgramのCompileメソッドを実行すると、コードに問題があるときにEJvInterpreterError例外が投げられます。
EJvInterpreterErrorのErrCodeプロパティとMessageプロパティで、エラーの内容を取得できます。
JvInterpreterProgramのLastError.ErrCodeプロパティやLastError.Messageでもエラーの内容を取得でき.LastError.ErrPosプロパティでエラーの場所がわかります。
begin
try
JvInterpreterProgram1.Compile;
except
on E : EJvInterpreterError do
begin
ShowMessage(Format('%d:%s', [E.ErrCode, E.Message]));
if E.ErrPos > -1 then
begin
Memo1.Text := JvInterpreterProgram1.Pas.Text;
Memo1.SelStart := E.ErrPos;
Memo1.SelLength := 0;
end;
end;
on E: Exception do
begin
ShowMessage(Format('%d:%s', [
JvInterpreterProgram1.LastError.ErrCode,
JvInterpreterProgram1.LastError.Message]));
if JvInterpreterProgram1.LastError.ErrPos > -1 then
begin
Memo1.Text := JvInterpreterProgram1.Pas.Text;
Memo1.SelStart := JvInterpreterProgram1.LastError.ErrPos;
Memo1.SelLength := 0;
end;
end;
end;