Hello, Raul.  On Tuesday, January 25, 2011, at 3:00:19 PM, you
wrote:

> On Tue, Jan 25, 2011 at 2:33 PM, Ron Jeffries <[email protected]> wrote:
>> Hello, Raul.  On Tuesday, January 25, 2011, at 2:22:29 PM, you wrote:
>>> nacct was initialized, in the previous block of code, to point
>>> at the record after the end of the previous set of loaded data.
>>
>> Yes ... but I think that the subsequent loops are looking up
>> accounts and trying to update them. Surely they are not ALL at the
>> end?

> If that record represents "the current day" and the previous
> journal record represents "previous days", updating only the
> current day's values would seem to be the right thing to do:
> Previous days' calculations should already be complete.
> (Though, granted, a paranoid programmer might want to
> deal with the case where those calculations had failed.)

> Note also that acct will be initialized with all 0s when the
> program starts.

I believe, perhaps erroneously, that all the accounts have been read
into the array, from 0 up to and not including nacct. Then, I
believe, still perhaps erroneously, that the transactions are being
read in subsequently (and they are not guaranteed to be in account
order). Then, IBPE, that the account is being looked up (where it
says look up the account) and that we are supposed to be updating
EACH account, none of which is at location acct[nacct], because that
cell was never initialized, which we see by the fact that the final
setting of nacct is +nacct at the END of the account read loop.

I would bet that if this program had tests, they would not run
correctly. I could be wrong, of course.

Ron Jeffries
www.XProgramming.com
Resistance may or may not be futile. It is for sure not productive.

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to