I have data in a datagrid and an item number may appear more than once for a particular order. This is because when the order shipped the item was shipped in multiple boxes and therefore each line represents the qty shipped for that "box" for that item.
For example
Order # Item # Qty Shipped
123 456 24
123 456 24
123 789 12
124 456 10
I need to update a database with this information but I need to update Order 123 for item 456 the qty of 48, then update order 123 for item 789 the qty of 12, then update order 124 for item 456 the qty of 10.
How do I loop thru the array or tab-delimited data to summarize the qty? Which is better to use an array or tab-delimited list?
Thanks, Dan
Loop thru an array
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Loop thru an array
Hi.
I am still new to arrays, but this seems ideally suited for one. If you have your data in a field, say, then in a button script put
I bet this can be shortened, but I just threw it together. I assumed you parsed your data as per your example, that is, with spaces.
Craig Newman
I am still new to arrays, but this seems ideally suited for one. If you have your data in a field, say, then in a button script put
Code: Select all
on mouseUp
put fld "yourField" into temp
repeat with y = 1 to the number of lines of temp
put word 1 of line y of temp & numtoChar(235) & word 2 of line y of temp && word 3 of line y of temp into line y of temp
end repeat
repeat with y = 1 to the number of lines of temp
add word 2 of line y of temp to accum[word 1 of line y of temp]
end repeat
combine accum using return and space
replace numtoChar(235) with space in accum
answer accum
end mouseUp
Craig Newman
Last edited by dunbarx on Thu Jul 22, 2010 7:29 pm, edited 2 times in total.
Re: Loop thru an array
Thanks, it worked great....