Trying to clear a list

I am trying to remove the elements in a list within LotusScript. This list holds the email addresses of a list of names that I have pulled from the document that is being processed. The list values are not held in any field within the document. These are list variables within the code of the agent.

Here is the code that I have.

This first list clears out as I want it to.

The second list does not clear out as the first one does.

Can anyone tell me what I am doing wrong?

ForAll planner In Planners

 If planner = "John Doe" Then

found = True

 Else

If ListTag(planner) = planner Then

	Erase planners(planner)

End If

 End If

End ForAll

ForAll address In EmailAddresses

If address = "John Doe" Then

found = True  

Else

If ListTag(address) = address Then

    	Erase EmailAddresses(address)

End If

End If

End ForAll

Thank you in advance for your comments.

Jean

Subject: Not how that works.

I would suggest having a counter and do a fulltrim on the array value when the if statement is true and the assign it back to the document withs a replaceitemvalue(“fieldname”,holdarray)

Subject: Try this…

ForAll address In EmailAddresses If address = “John Doe” Then

found = True

Else

Print “-------------------------”

Print "ListTag = " & ListTag(address)

Print "Value = " & address

Print “”

If ListTag(address) = address Then

Erase EmailAddresses(address)

End If

End If

End ForAll

You should now be able to see the two values and then hopefully figure out what is wrong.

I suspect that the listtag and the value are not identical, and that is why nothing is deleted.

Subject: Thank you for the idea…

Karl-Henry, I would like to thank you for your comment… found the problem. Because I am bringing in the new email address, the list tag had the first and last name only and not the email address so this was the reason this was not removing the elements…

THANK YOU!!! This has been a real learning issue. I will definitely remember this in the future.

Have a GREAT DAY!!!

Subject: Also why it’s a great idea to learn to use the debugger, you would have seen that straight away.

Subject: What do you see as the values when stepping through with debugger?

Subject: Trying to clear a list

When the code runs through the Planners list, that list is completely emptied, but when the code runs on the EmailAddresses list, the list contains the same values as when it started.

The emailaddresses list is used in the maildoc.sendto field when sending out the email notifications.

This one has me baffled as to why the second part of the code for the emailaddresses list doesn’t empty.

Thanks in advance for your comments.

Also to note, this is code in an agent that runs on documents in a specific view.

Again thank you for your comments.