Problem with List and ForAll

Hi, I am trying to clean up some old data.

I have a contact management database in which all contact names are plopped into one text field. I am researching now how the names are structured so I can complete my parser to split the names into Title, First, Middle and Last.

So to that end I wrote an agent to count how many parts are in each name. It works well, but when I want to see the results in a report, it will not output like I am expecting.

I have this code (which works when I watch it in the debugger)

Do Until thisdoc Is Nothing

	FullName = thisdoc.contactname(0)

	Print "Processing: " & fullname

	NamePart = StrTok(fullname, " ")

	partcount  = 0

'####### put it in an array so we can see how many elements there are.

	While NamePart <> ""		

		Redim Preserve NameArray(partcount)

		NameArray(partcount) = Trim(NamePart)

		partcount = partcount+1

'## get the next token	

		NamePart = StrTok(Null, Null)

	Wend

	

	If Iselement(ElementCount(partcount)) Then

		ElementCount(partcount) = ElementCount(partcount)+1

	Else

		ElementCount(partcount) = 1

	End If

	

	Set thisdoc = col.getNextDocument(thisdoc)

	total = total +1

Loop

Watching the Values in the debugger shows me:

ElementCount [143, 19, 2, 4]

2		143

3		19

4		2

So I know the List is being built like I expect.

so 143 names have 2 parts,

19 names have 3 parts

and so on.

but when it gets to the report part:

Set nlog = New NotesLog(“NamePartsCounter”)

Forall c In ElementCount

	report = report & ElementCount(c) & " Names with " & Listtag(c) & " parts" & cr 

End Forall



report = total & " Total Records Processed" & cr & report	



nlog.OpenMailLog "Andy Seubert","PartsCounter Report"

nlog.LogAction cr & report & cr

nlog.Close	

Which is right after the above code, not a function call or anything,

It tells me:

06/24/2003 12:09:22 PM NamePartsCounter starting

06/24/2003 12:09:22 PM

41085 Total Records Processed

35630 Names with 6 parts

35630 Names with 0 parts

504 Names with 7 parts

504 Names with 13 parts

which is worthless and plain wrong.

I am stuck, can anyone tell me what I am doing wrong?

Thanks

–Andy

1		4

Subject: Problem with List and ForAll

From

Forall c In ElementCount

	report = report & ElementCount(c) & " Names with " & Listtag(c) & " parts" & cr 

End Forall

To

Forall c In ElementCount

	report = report & c & " Names with " & Listtag(c) & " parts" & cr 

End Forall

Duh…