Early Morning Revelation The Second

chaoticset on 2001-09-30T09:12:45

This is the second time that I've spent the whole night up and figured out a workable solution only a pot of coffee and hours later than I should be awake.

I was scribbling while sipping my cold coffee and thinking, "I'm going to sleep soon, God dammit. I have a big, honking, nasty day ahead of me." It always seems like the revelation comes all at once, but it does not. It comes in bits, the deception like a drink of water: To us, it is a single unit of something, but in reality, it is concerted effort on the part of reality.

Okay, I'm babbling. The point is, I thought, "Well, if I've got to match it, it'd help if it were sorted."

"Well, yeah, but I can't really sort it - I don't know how - unless I load it into an array and then dump the array back into the inventory file after."

"I guess I'll have to. Lessee... ::scribble scribble:: ...okay, that's there, and then...oooh, I could just load it in as an array at the beginning of the whole program and modify the array and then write the array back. Even for a database of a few thousand, that probably wouldn't take too long..."

"...okay. Drop the whole file into a 2-d array, 3 values by ever-how-many product in the inventory...then sort the array by the 0th value in each...next, match the (hopefully relatively few) new values to the whole product names and if they connect, increment the value in slot 1 of the array by the value for the amount of new product. If they're not, append it to the array and worry about it on the next sweep (because there's going to be sorting at almost every layer, and unsorted new inventory isn't a terrible tragedy, fix it later if it's a problem) so then I just dump it back to the inventory file."

Well, the scribbled version looks a lot more comprehensible. Maybe it's just the time, but that ALL looks like babble now.

I hope it isn't.