|Re: Program only works when stepping, not when running?|
Message #6 Posted by Mark Edmonds on 6 Nov 2008, 6:58 a.m.,
in response to message #5 by Mike T.
Thanks for all your help chaps. With the benefit of a clearer brain today, I can now explain exactly what was going wrong. The route cause of the problem was operator error! I could see where things were going wrong but I was totally on the wrong track.
I typed in the program, ran it and found it gave wrong results so I stepped through it and found it gave right results. This totally confused me and made me look at things the wrong way - I thought it was a bug in the 32sII or my program, not that it was actually my fault!
The reason is that when I was stepping through, after the Enter command, I was checking the stack contents by using "x swap y" which of course, enabled stack lift and therefore cancelled the disabled stack lift after the Enter command. Hence, the stepped run gave the right answer. Had I tried stepping through the program without checking the stack, I would have found that it also gave the wrong answer!
So, like most code mysteries, the cause was simple operator error and me looking for the solution in the wrong place (which had I applied my 5 minute rule, I would have stopped doing).
A somewhat embarrassing saga but a good one to learn and a nice way to remind myself that even if you consider yourself competent at programming, simple mistakes are still simple to make! :)