|
我编制了一个文字连接程序,编译链接均正常,但在CAD调入运行时出现严重错误,造成系统崩溃,请各位帮忙查找错误.
//====连接文字=======================================================
void join::jointxt(ads_name text,ads_name text1)
{
struct resbuf *la,*ed,*ep;
TCHAR textstr[1001],textstr1[1001],tmp[2001],tmp1[1001],*txt=_T(""),*txt1=_T("");//*txt=new TCHAR[1001],*txt1=new TCHAR[1001];
ads_real textrz,dist;
ads_point pick,p1,p2,pt1,pt2,pp;
int len,len1;
ed=acdbEntGet(text1); //取得后续实体参数集
la=entitem(ed,1); //获得文本串的内容
_tcscpy(textstr1,la->resval.rstring);
ed=acdbEntGet(text); //取得基准实体参数集
la=entitem(ed,1); //获得文本串的内容
_tcscpy(textstr,la->resval.rstring);
acedTextBox(ed,pt1,pt2);
la=entitem(ed,10); //获得文本的插入点
pick[0]=la->resval.rpoint[0];
pick[1]=la->resval.rpoint[1];
la=entitem(ed,50); //获得文本的旋转角度
textrz=la->resval.rreal;
len=_tcslen(textstr);
len1=_tcslen(textstr1);
if(lenresval.rpoint[0]=pick[0];
la->resval.rpoint[1]=pick[1];
txt=str_trimright(txt); //删除字串尾部
符、TAB符以及空格
txt=spacecntrl_strtrim(txt);
_tcscpy(tmp,txt);
_tcscat(tmp,tmp1);
ep=strrealloc(ed,tmp);
acdbEntDel(text1);
acdbEntMod(ep); //程序运行至此完蛋?
acutRelRb(ed);
// delete txt,txt1;
}
else
{
acedAlert(_T("字串太长,不能超过1000个字符!"));
acutRelRb(ed);
}
}
//=====主程序========================================================
void join::txtmjoin()
{
int old1,old2,new1,new2;
ads_name ename,ename1;
ads_point ptres;
struct resbuf *etype,*tlist;
new1=0;new2=0;
change_var(_T("blipmode"),new1,&old1);
change_var(_T("cmdecho"),new2,&old2);
if(acedEntSel(_T("\n请拾取基准文字串:\n"),ename,ptres)!=RTCAN)
{
tlist=acdbEntGet(ename);
etype=entitem(tlist,0);
if(etype!=NULL && (_tcscmp(etype->resval.rstring,_T("TEXT")))==0)
{
if(acedEntSel(_T("\n再拾取后续文字串:\n"),ename1,ptres)!=RTCAN)
{
tlist=acdbEntGet(ename1);
etype=entitem(tlist,0);
if(etype!=NULL && (_tcscmp(etype->resval.rstring,_T("TEXT")))==0)
{
jointxt(ename,ename1);
}
else
{
acdbFail(_T("\n未选中文本实体"));
}
}
else
{
acdbFail(_T("用户中断\n"));
}
}
else
{
acdbFail(_T("\n未选中文本实体"));
}
}
else
{
acdbFail(_T("用户中断\n"));
}
acutRelRb(tlist);
change_var(_T("blipmode"),old1,&new1);
change_var(_T("cmdecho"),old2,&new2);
} |
|