LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

DRAWING FOR Stack overflow (error discussion)

Root / Programming Questions / [.]

Giant_GamerCreated:
DRAWING FOR Stack overflow in 0:335
This error popped up during the writing of the program LOTTO. I had just about finished adding the whole 2nd mode for the PowFaux Ball. This error points not to the line that caused it, and seeing as I could not find much information on this particular error with the search, I would like to take a stab at explaining it. (and probably not very thoroughly) Line 335 (in my current version of LOTTO that I will be updating soon) reads as such:
333 IF DATE>=10 THEN 
334      LOCATE 12,YCORD
335      ? DATE;" ";MONTH$
336  ENDIF
So that didn't help solve the problem. Googling the term directly offered no help on the subject, but some C help did mention "FOR stack overflow". with the recommendation that there was an open IF statement. I browsed the code for all IF's and ENDIF's. still nothing. When I was still hitting dead ends, I backed up LOTTO as "LOTTOX". And started to remove sections of the recently added code, and testing the program. That is when I found a possible error, at first I thought it was unrelated... in line 291
IF LOGO==2 THEN GOSUB @CASHCHECK
... in reference to lines 324-328
324   @CASHCHECK
325   IF WIN==5 THEN @JACKPOT
326   IF WIN==4 THEN INVEST=INVEST+375:BEEP 32:LOWWIN=LOWWIN+1:GOTO @PRINT
327   IF WIN==3 THEN INVEST=INVEST+12:BEEP 7:MIDWIN=MIDWIN+1
328   '---
I had used GOSUB with no RETURN and cycled the program adding a new gosub after gosub. after a few thousand loops then the error pops up. I changed GOSUB to GOTO, and after testing it, the error vanished. (yes I know that I dyslexicly swapped low-win and mid (middle) win) If you are interested you can put the error back into the program and see how long it takes before it's declared a problem. Hilariously when showing this bug to a friend, I won the lotto before the error popped up! XD TL:DR So if you find yourself with the error, I would check for open GOSUB statements.