【问题标题】:More detailed error from runbuf function in Dynamics AXDynamics AX 中 runbuf 函数的更详细错误
【发布时间】:2016-07-17 20:03:49
【问题描述】:
我尝试构建某种 X++ 脚本执行器,因此使用了 runbuf 函数。
只要我传入的 X++ 代码有效,它就可以工作,但是当我传递无效代码时,它只会抛出一个错误,即它无法编译代码但没有更多详细信息。
例如,当我尝试以下代码时
runbuf('void dynAdd(int lhs, int rhs) { return lhs + rhs; }');
错误提示失败
无法编译“void dynAdd(int lhs, int rhs) { return lhs + rhs;
}”。
有没有办法获得有关错误的更多信息?
提前致谢
【问题讨论】:
标签:
axapta
dynamics-ax-2012
x++
dynamics-ax-2009
dynamics-ax-2012-r3
【解决方案1】:
你可以像这样使用XppCompiler
static void DynamicXppTest(Args _args)
{
str dynamicXpp;
int result;
XppCompiler xppCompiler;
;
dynamicXpp = 'void dynAdd(int lhs, int rhs) { return lhs + rhs; }';
// previous runbuf - style
//
// result = runbuf(dynamicXpp, 3, 4);
// info(strfmt("result = %1", result));
xppCompiler = new XppCompiler();
if (xppCompiler.compile(dynamicXpp))
{
result = xppCompiler.execute(3, 4);
info(strfmt("result = %1", result));
}
else
{
error(xppCompiler.errorText());
}
}
这将导致信息日志中出现以下错误
*** 错误:82,操作数与函数类型不兼容。