高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】odstring = operator
odstring "+" operator
odstring "+" operator
it lools like that, in dd2.0.3 this syntax does not work :
timestring = timestring + "," + tostring(precord->dashlengthat(i));
i use this loop, and the string does not cumulate :
odstring timestring;
ddblinetypetableptr plintypetable = pdb->getlinetypetableid().safeopenobject();
oddbsymboltableiteratorptr piter = plintypetable->newiterator();
// iterate in the table contents
for (piter->start(); !piter->done(); piter->step())
oddblinetypetablerecordptr precord = piter->getrecordid().safeopenobject();
if (precord->numdashes())
{
timestring = (precord->isscaledtofit() ? " , s" : " , a");
for (int i=0; i < precord->numdashes(); i++) {
timestring = timestring + "," + tostring(precord->dashlengthat(i));
printf("%s\n",(const char*)timestring, );fflush(stdout);
}
what is wrong with this ?
thanks
jp
hi,
the problem is inside odstring tostring(const double val).
code:
odstring tostring(const double val)
{
odstring temp;
if (fabs(val) < 1e6)
{
temp.format(dd_t("%.4f"), val);
/***********************************************************************/
/* strip all but one trailing zero from buffer */
/***********************************************************************/
for (int n = temp.getlength(); ((temp[n-2] != '.') && (temp[n-1] == '0')); n--)
{
temp.setat(n-1, '\0');
}
}
else
{
temp.format(dd_t("%.4e"), val);
}
return temp;
}
temp.setat(n-1, '\0'); generates invalid string. it can be fixed by changing to
code:
temp = temp.left(temp.getlength() - 1);
oups ! tostring() was taken from the sample dbdumper.cpp !
should be corrected there !
rgds
jp
yes, of course. i have fixed it already.
|