I'm looking for a way to extract the values of column value stored in the SysLastValue
table.
i was trying to store it in txt file but the content of text file is unreadable
static void jobSettingStore(Args _args)
{
syslastvalue sysLastValue;
container dataContainer;
BinData binData;
container blobContainer;
ContainerClass containerClass;
str settingsFileName = "c:\\settings.txt";
dataContainer = xSysLastValue::getValue(curExt(), curUserId(), UtilElementType::Usersetup, 'Mytable', 'myDesignName');
containerClass = new ContainerClass(dataContainer);
blobContainer = containerClass.toBlob();
binData = new BinData();
binData.setData(blobContainer);
binData.saveFile(settingsFileName);
}
Is there another way to store this value in an XML file?
For most packed classes you can simply do a con2str
of the container to get a readable content. This will not work if the container has nested containers. And user setup containers has!
It can be solved by using a recursive function:
static void con2xmlTest(Args _args)
{
container con;
str con2xml(container c, str ind = '', str sep = ' ')
{
int idx = 0;
int len = conLen(c);
str tmp;
str retStr;
while (idx < len)
{
idx += 1;
if (typeOf(conPeek(c,idx)) == Types::Container)
retStr += ind + sep + con2xml(conPeek(c,idx), ind+sep) + '\n';
else
{
tmp = conPeek(c,idx);
retStr += strFmt(ind + sep + '<%2>%1</%2>\n', tmp, typeOf(conPeek(c,idx)));
}
}
return strFmt('<%2>\n%1</%2>', retStr + ind , Types::Container);
}
info(con2xml([1,2.0,["3",today()]]));
con = xSysLastValue::getValue(curExt(), curUserId(), UtilElementType::Usersetup, 'CustTable', '');
info(con2xml(con));
}
The output is readable except for humans.