Here's what I'm trying to do slightly based on some of the ideas in yours:
I know its not, but in my mind, this is what this current event list is doing:
Checks every X value to determine if ItemName exists. If it does, set the loopindex (which would be the CurX of the array) to a variable to add to the existing item's quantity. If it doesn't exist but finds an "unassigned" value, adds the item to inventory. If neither are true (meaning the item is not currently in the inventory and there is no bag space), do nothing.
I'm beginning to think loopindex isn't working like I think it is, however.