几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】odstring = operator (http://www.dimcax.com/hust/showthread.php?t=17764)

yang686526 2009-05-06 09:09 PM

【转帖】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.


所有的时间均为北京时间。 现在的时间是 05:16 AM.