ordelore wrote:
You don't need a return or an end because a return signifies the end of a subroutine and/or the program. Axe will automatically add the return. an end is not necessary.
The "End" is indeed unnecessary but the return at the end is still a good idea to put, to avoid getting bad habits. Axe won't add a Return if there is already one so you don't waste space (but in the present case, not only the "End" is useless but a "Return" is added too).

GinDiamond wrote:
What the heck is going on with this code? I compiled it today with no changes with the last compilation, yet it exits as soon as it starts.


Code:

<snipped>


I have a feeling the Return is doing something. Am I right?
Have you just tried in our mind what your program does ? Have you noticed that you put your subroutine inside your main loop ? Have you thought about indenting your code to avoid such mistakes ?

Because the problem is quite simple:
-the program reads the "Repeat getKey(15)" and doesn't quit since you don't hold the Clear key
-it reads the bunch of "If/ElseIf/..." and changes X and Y accordingly
-It hits the "End" of the "If"
-It does the sub(CS) and DispGraph and the sub(CS) again.
-then it enters the Lbl CS
-it Pt-Changes
-it hits Return and quits
-all of this happened so fast you thought nothing happened
-it never reads the "End" at the end, nor the "Return" that is automatically added

How to fix the problem:
I guess you should just move the "End" of the End and put it right after the second sub(CS). You could also add a Return right after it, to avoid getting bad habits, but at worst, the program will Pt-change for nothing then quit after it hits the End of the loop.

And as I said, code indenting helps, because if you had tried to indent your code, you'd have noticed that your routine is inside the loop.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement