cancel
Showing results for 
Search instead for 
Did you mean: 

Loop problem

david_fryda2
Participant
0 Kudos

Hi everyone,

I have a strange problem regarding a loop.

I have a node which has 8784 lines.

I created an inputfield in the view thus the user can insert a string and an algorithm performs a search for him (displaying what he want in the table).

Here is the code :


IEt_Emp_Resp_TmpNode node = wdContext.nodeEt_Emp_Resp_Tmp();
int i=0;		
		wdComponentAPI.getMessageManager().reportSuccess("node.size() == " + node.size());		
	    for(i=0; i<node.size(); i++)
	    {
				IEt_Emp_Resp_TmpElement e = node.getEt_Emp_Resp_TmpElementAt(i);
				if (! e.getPernr().equals(text))
				{
					node.removeElement(e);
				}
	    }
		wdComponentAPI.getMessageManager().reportSuccess(">> " + i);

The problem is the loop doesn't go till 8784 but stops at

4393.

Can someone help ?

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

David,

When removing elements, loop in reverse direction:


for(i = node.size() - 1; i>=0; i--) {
...
}

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Answers (1)

Answers (1)

former_member182372
Active Contributor
0 Kudos

Hi David,

Your for condition is incorrect. Try


for (int i = node.size() - 1; i >= 0; i--)

Best regards, Maksim Rashchynski.