Struct Resbuf BRRRRRR.....

Struct Resbuf BRRRRRR.....

Anonymous
Not applicable
786 Views
4 Replies
Message 1 of 5

Struct Resbuf BRRRRRR.....

Anonymous
Not applicable
well is seems i'm still not getting the hang of it:

I want to add Xdata to objects, some of these entities need to have
extra xdata.


xd=acutbuildlist(-3, 1001, "MYAPPDATA", 1040, Scale, 1040, ref, RTNONE);
xd2 = xd; // i think i copy xd into xd2 wich needs more xdata

AddXdata=ads_acutbuildlist(1000, _T("EXTRA_STRING for XD2"), RTNONE);
append_rblist (&xd2, AddXdata);

Now it appears xd == xd2;
but i don't want this, i want xd with 2x 1040 and xd2 same as xd but
with the extra 1000.

What am i'm doing wrong ?

How do i copy xd into xd2 and add extra data to the xd2 without changing
xd ?

thank you !!!
0 Likes
787 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Ok, here's how I do it. I have a routine to start an Xdata resbuf and
routines to add Integers, Stirngs, Reals, etc to that resbuf. Here's how I
would create your resbuf ...

pXdata = StartXdataResbuf( _T("MYAPPDATA"));
AddRealXdata( 1040, Scale, pXdata );
Add RealXdata( 1040, ref, pXdata );
AddStringXdata( 1000, _T("EXTRA_STRING"), pXdata );


And here are the Xdata Functions ...

resbuf *StartXdataResbuf( TCHAR *szAppName )
{
struct resbuf *pRb;
struct resbuf *pTmp;

pRb = acutNewRb( RTSHORT );
pRb->restype = -3;
pRb->resval.rint = 0;

pTmp = pRb;
pTmp->rbnext = acutNewRb( RTSTR );
pTmp = pTmp->rbnext;
pTmp->restype = 1001;
pTmp->resval.rstring = (TCHAR *) malloc(( _tcslen( szAppName ) + 1 ) *
sizeof( TCHAR ));
_tcscpy( pTmp->resval.rstring, szAppName );
pTmp->rbnext = NULL;

return( pRb );
}


void AddStringXdata( int nCode, TCHAR *szTxt, resbuf *pEbuf )
{
struct resbuf *pTmp;

pTmp = pEbuf;
while( pTmp->rbnext != NULL ) {
pTmp = pTmp->rbnext;
}

pTmp->rbnext = acutNewRb( RTSTR );
pTmp = pTmp->rbnext;
pTmp->restype = nCode;
if ( szTxt == NULL ) {
pTmp->resval.rstring = (TCHAR *) malloc( 1 * sizeof( TCHAR ));
_tcscpy( pTmp->resval.rstring, _T("") );
} else {
pTmp->resval.rstring = (TCHAR *) malloc(( _tcslen( szTxt ) + 1 ) *
sizeof( TCHAR ));
_tcscpy( pTmp->resval.rstring, szTxt );
}
pTmp->rbnext = NULL;

}

void AddRealXdata( int nCode, double dVal, resbuf *pEbuf )
{
struct resbuf *pTmp;

pTmp = pEbuf;
while( pTmp->rbnext != NULL ) {
pTmp = pTmp->rbnext;
}

pTmp->rbnext = acutNewRb( RTREAL );
pTmp = pTmp->rbnext;
pTmp->restype = nCode;
pTmp->resval.rreal = dVal;
pTmp->rbnext = NULL;

}


I also have routines for Adding Integers, Longs and Handles.

Hope this helps,

Joe

"SixFeet6" wrote in message
news:5903035@discussion.autodesk.com...
well is seems i'm still not getting the hang of it:

I want to add Xdata to objects, some of these entities need to have
extra xdata.


xd=acutbuildlist(-3, 1001, "MYAPPDATA", 1040, Scale, 1040, ref, RTNONE);
xd2 = xd; // i think i copy xd into xd2 wich needs more xdata

AddXdata=ads_acutbuildlist(1000, _T("EXTRA_STRING for XD2"), RTNONE);
append_rblist (&xd2, AddXdata);

Now it appears xd == xd2;
but i don't want this, i want xd with 2x 1040 and xd2 same as xd but
with the extra 1000.

What am i'm doing wrong ?

How do i copy xd into xd2 and add extra data to the xd2 without changing
xd ?

thank you !!!
0 Likes
Message 3 of 5

Anonymous
Not applicable
thats nice, but not really my problem. Adding xdata isn't the problem but using 2 different type of RB's.

Suppose you want to add 2 strings to 1 entity and the same 2 strings + some extra xdata.

My problem is: i get and *XD as a variable inside a function

A want to use this *XD for 1 entity and the same xdata from *XD + some extra xdata to another entity.

I supposed when doing XD2 = XD;
I still could use XD and add some extra xdata to XD2

But when i verify the entities all entities seem to have XD2 data although i added only XD to some of them.

thx !
0 Likes
Message 4 of 5

Anonymous
Not applicable
When you do XD2 = XD, all you are doing is setting the pointer of XD2 to
point to the same chunk of memory that XD is pointing to. You need a
routine that would copy one resbuf to another. When you write such a
routine, you'll have to allocate new memory for each resbuf structure and if
you are copying a string, you'll need to allocate new memory for the string
itself. resbuf is a structure, not a class so there is no copy constructor
when you do XD2 = XD.

Joe

wrote in message news:5903102@discussion.autodesk.com...
thats nice, but not really my problem. Adding xdata isn't the problem but
using 2 different type of RB's.

Suppose you want to add 2 strings to 1 entity and the same 2 strings + some
extra xdata.

My problem is: i get and *XD as a variable inside a function

A want to use this *XD for 1 entity and the same xdata from *XD + some extra
xdata to another entity.

I supposed when doing XD2 = XD;
I still could use XD and add some extra xdata to XD2

But when i verify the entities all entities seem to have XD2 data although i
added only XD to some of them.

thx !
0 Likes
Message 5 of 5

Anonymous
Not applicable
Ok, i already thought this was the problem.





Joe A schreef:
> When you do XD2 = XD, all you are doing is setting the pointer of XD2 to
> point to the same chunk of memory that XD is pointing to. You need a
> routine that would copy one resbuf to another. When you write such a
> routine, you'll have to allocate new memory for each resbuf structure and if
> you are copying a string, you'll need to allocate new memory for the string
> itself. resbuf is a structure, not a class so there is no copy constructor
> when you do XD2 = XD.
>
> Joe
>
> wrote in message news:5903102@discussion.autodesk.com...
> thats nice, but not really my problem. Adding xdata isn't the problem but
> using 2 different type of RB's.
>
> Suppose you want to add 2 strings to 1 entity and the same 2 strings + some
> extra xdata.
>
> My problem is: i get and *XD as a variable inside a function
>
> A want to use this *XD for 1 entity and the same xdata from *XD + some extra
> xdata to another entity.
>
> I supposed when doing XD2 = XD;
> I still could use XD and add some extra xdata to XD2
>
> But when i verify the entities all entities seem to have XD2 data although i
> added only XD to some of them.
>
> thx !
0 Likes