I have the following information which I have have got from a fld.
Alpha 200, Beta 100, Charlie 300, Delta 400, Alpha 100, Charlie 300
I want to use a repeat loop to put them into another table with the names in the first column and numbers totaled by name in the 2nd column. I have managed to get:
Alpha 200
Beta 100
Charlie 300
Delta 400
Alpha 100
Charlie 300
but what I really want is:
Alpha 300
Beta 100
Charlie 600
Delta 400
Any suggestions?
I have almost got it to work but end up with gaps in the name column and superfluous info in the number column of the same line.[/code]
grouping and accumulating in a table
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Code: Select all
constant cItems = "Alpha 200, Beta 100, Charlie 300, Delta 400, Alpha 100, Charlie 300"
on mouseUp
set the itemDelimiter to comma
put empty into tArray
repeat for each item tItem in cItems
put word 1 of tItem into tKey
if tArray[tKey] is empty then
put 0 into tArray[tKey]
end if
add word 2 of tItem to tArray[tKey]
end repeat
combine tArray with return and space
sort tArray
put tArray
end mouseUp