An issue with the stack maybe?

I have encountered a problem that appears like it might be related to the stack if the basic stamp uses a stack like I assume it does. I call this particular routine but it never returns and instead resets the stamp. “Found it” prints but neither “fell through” or “Back” does. This call to find_motion is the one and only call to that routine. Any Ideas?

GOSUB find_motion
DEBUG " Back ",CR
PAUSE 1400

''DEBUG "Finding Motion", CR
GOSUB Sweep_find
Whereisit = 0
DEBUG "found it",CR
'PAUSE 2000

DEBUG "fell through"


  • MarkCrCo.

    The BS2 is limited in how many GOSUBs that can be nested. (GOSUB does a GOSUB which does a GOSUB, etc.)

    I think the limit is 8 but it's mentioned in the BASIC Stamp Manual.
  • The limit is 4. See the description in the chapter on the GOSUB statement in the Basic Stamp Manual
  • Would have to see the entire program, but what you show there will fall into the subroutine after the PAUSE 1400.
    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
  • There is more code after the pause 1400 which includes an end statement. I'll check on the number of gosubs, it is possible I have too many.
Sign In or Register to comment.