1

当我将 RecId 存储在 anytype 对象中时,该数字已损坏。在我的实现中,我将 RecId 存储在树视图项的数据值字段中。每当我检索数据值时,我保存的数字总是发生很大变化。有什么建议么?

这是一个例子:

void fillTree()
{
    ABC_Menus _ABC_Menus;
    TreeItemIdx parentItemIdx;
    ;
    while select Prompt, RecId from _ABC_Menus
    {
        parentItemIdx = SysFormTreeControl::addTreeItem(formTreeControl, _ABC_Menus.Prompt, FormTreeAdd::Root, _ABC_Menus.RecId, 0, true);
    }
}

public void endLabelEdit(int _idx, str _text, anytype _data)
{
    FormTreeItem formTreeItem = this.getItem(_idx);
    ;
    formTreeItem.text(_text);
    this.setItem(formTreeItem);
    info(_data);     //this number comes out all wrong
    super(_idx, _text, _data);
}

我将 RecId 存储在树值字段中。但是,如果我稍后检索它,则会返回一个完全不同的数字。
- 表中的 RecId:5637144588
- endLabelEdit 方法显示的 RecId:202520592908288

在字段中存储 RecId 时,我还尝试使用 num2str(ABC_Table.RecId, 0, 0, 0) 。以这种方式存储时,数字匹配,但会引发“分配/比较失去精度”警告。可以吗,还是有更好的方法?

谢谢

4

2 回答 2

3

在 Axapta 版本 3 之后,所有 RecId 都是 64 位整数。strFmt() 函数能够为您将 recId 从 int64 转换为字符串,但您也可以使用 int642str() 函数将 recId 显式转换为字符串。

RecId recId = 5637144577;
anytype a;
int64 b;
;

a = recId;
b = a;

info(int642str(a));
info(int642str(b));
info(int642str(recId));
于 2009-12-08T19:36:47.103 回答
2

请向我们提供完整示例:

RefRecId   recid = 5637144577;
anytype    tmp;
;
info(strfmt('%1', recid));
tmp = recid;
info(strfmt('%1', tmp));
recid = tmp;
info(strfmt('%1', recid));

结果是:

5637144577

5637144577

5637144577

于 2009-12-08T07:33:38.180 回答