RETURN Example

BS1 icon BS2 icon BS2e icon BS2sx icon BS2p icon BS2pe icon BS2px icon

Syntax: RETURN

 

 

 

NOTE: This is written for the BS2 and will run on any BASIC Stamp module. Modify the $STAMP directive (as required) before downloading to the BS1, BS2e, BS2sx, BS2p, BS2pe, or BS2px.

' RETURN.BS2
' This program demonstrates a potential bug caused by allowing a program to
' "fall into" a subroutine.  The program was intented to indicate that it
' is "Starting...", then "Executing Subroutine,", then "Returned..." from
' the subroutine and stop.  Since we left out the END command (indicated in
' the comments), the program then falls into the subroutine, displays
' "Executing..." again and then RETURNs to the start of the program and
' runs continuously in an endless loop.

' {$STAMP BS2}


Reset:
  DEBUG "Starting Program", CR          ' show start-up

Main:
  PAUSE 1000
  GOSUB Demo_Sub                        ' call the subroutine
  PAUSE 1000
  DEBUG "Returned from Subroutine", CR  ' show that we're back
  PAUSE 1000
                                        ' <-- Forgot to put END here

Demo_Sub:
  DEBUG "  Executing Subroutine", CR    ' show subroutine activity
  RETURN

Go to Welcome page

BASIC Stamp Help Version 2.5.4

Copyright © Parallax Inc.

8/8/2012