while loop

while loop

Anonymous
Not applicable
273 Views
1 Reply
Message 1 of 2

while loop

Anonymous
Not applicable
I am trying to get a while loop to cycle through
all the attributes

My loop never advances and I can't figure out how
to get ent=nextone

 

I have this

 

 while
(acdbEntNext(ent,nextone))//cycle through all
attributes
  {
   //rc=acdbEntNext(ent,nextone);//get
the next entity
   rbTrav=acdbEntGet(nextone);//set that as
our target
   if(!rbTrav)//if I don't get the target
quit
    {acutPrintf("\nFailed to get target entities
data. ");return;}
   
   while(rbTrav)//go
through the result
buffer
   {
    switch(rbTrav->restype)
    {
    case
0://insert or attribute tag
string
     strcpy(lyrName,
rbTrav->resval.rstring);
     strcat(lyrName,
"--0");
     RetVal=MessageBox(NULL,lyrName ,
"entity info
",MB_OK);
     break;
    case
8://layer name
     strcpy(lyrName,
rbTrav->resval.rstring);
     strcat(lyrName,
"--8");
     RetVal=MessageBox(NULL,lyrName ,
"entity info
",MB_OK);
     break;
    case
2://block name
     strcpy(lyrName,
rbTrav->resval.rstring);
     strcat(lyrName,
"--2");
     RetVal=MessageBox(NULL,lyrName ,
"entity info
",MB_OK);
     break;
    case
100:
     strcpy(lyrName,
rbTrav->resval.rstring);
     strcat(lyrName,
"--100");
     RetVal=MessageBox(NULL,lyrName ,
"entity info
",MB_OK);
     break;
    case
5://handle
     strcpy(lyrName,
rbTrav->resval.rstring);
     strcat(lyrName,
"--5");
     RetVal=MessageBox(NULL,lyrName ,
"entity info
",MB_OK);
     break;
    case
1://attribute textstring when using
entnext
     strcpy(lyrName,
rbTrav->resval.rstring);
     strcat(lyrName,
"--1");
     RetVal=MessageBox(NULL,lyrName ,
"entity info
",MB_OK);
     break; 
    }//switch
statement
    rbTrav=rbTrav->rbnext;//next item in
result buffer
    //*******right here I need
to set ent=nextone but that give me an
error.***************
   }//while
loop
0 Likes
274 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Hi Mike,

I tried your code, i couldn't figure it out why the
acdbentnext is not working in your code.

I tried this code , which is working for me, 
I hope you can make this code to suit your need.

<code_begin>

void ent_next()
{
 // TODO: Implement
the command
 struct resbuf * rb = NULL;
 ads_name erstes;

 int abbruch = 0 , i =0,j = 0; 
   

 

 if (acdbEntNext(NULL, erstes) != RTNORM)
abbruch = 1;
 while (abbruch == 0 )
 {

  rb=acdbEntGet(erstes);
  while (rb != NULL)

  {
   j = j+1;
   rb =
rb->rbnext;
  }
   acutPrintf("\n Number of
attributes : %d",j);
  i = i+1;
  if
(acdbEntNext(erstes, erstes) != RTNORM)

  {
   abbruch = 1;

   acutPrintf("\n count of entities :%d ",
i);
  }
 }


}

 

<code_end>

i hope this helps.

Cheers,

Varadan


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

I am trying to get a while loop to cycle through
all the attributes

My loop never advances and I can't figure out how
to get ent=nextone

 

I have this

 

 while
(acdbEntNext(ent,nextone))//cycle through all
attributes
  {
   //rc=acdbEntNext(ent,nextone);//get
the next entity
   rbTrav=acdbEntGet(nextone);//set that as
our target
   if(!rbTrav)//if I don't get the target
quit
    {acutPrintf("\nFailed to get target entities
data. ");return;}
   
   while(rbTrav)//go
through the result
buffer
   {
    switch(rbTrav->restype)
    {
    case
0://insert or attribute tag
string
     strcpy(lyrName,
rbTrav->resval.rstring);
     strcat(lyrName,
"--0");
     RetVal=MessageBox(NULL,lyrName ,
"entity info
",MB_OK);
     break;
    case
8://layer name
     strcpy(lyrName,
rbTrav->resval.rstring);
     strcat(lyrName,
"--8");
     RetVal=MessageBox(NULL,lyrName ,
"entity info
",MB_OK);
     break;
    case
2://block name
     strcpy(lyrName,
rbTrav->resval.rstring);
     strcat(lyrName,
"--2");
     RetVal=MessageBox(NULL,lyrName ,
"entity info
",MB_OK);
     break;
    case
100:
     strcpy(lyrName,
rbTrav->resval.rstring);
     strcat(lyrName,
"--100");
     RetVal=MessageBox(NULL,lyrName ,
"entity info
",MB_OK);
     break;
    case
5://handle
     strcpy(lyrName,
rbTrav->resval.rstring);
     strcat(lyrName,
"--5");
     RetVal=MessageBox(NULL,lyrName ,
"entity info
",MB_OK);
     break;
    case
1://attribute textstring when using
entnext
     strcpy(lyrName,
rbTrav->resval.rstring);
     strcat(lyrName,
"--1");
     RetVal=MessageBox(NULL,lyrName ,
"entity info
",MB_OK);
     break; 
    }//switch
statement
    rbTrav=rbTrav->rbnext;//next item in
result buffer
    //*******right here I need
to set ent=nextone but that give me an
error.***************
   }//while
loop
0 Likes