BASIC stamp manual v2.2
5: BASIC Stamp Command Reference – ON
BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com • Page 291
Demo Program (ON-GOSUB.bs2)
' ON-GOSUB.bs2
' This program demonstrates a simple task manager that can be used
' in a variety of applications. It is particularly useful in
' robotics and industrial applications. The advantage of this
' design is that task code modules may be called from other places
' in the program, including other tasks, and the overall program flow
' is maintained.
' {$STAMP BS2}
' {$PBASIC 2.5}
task VAR Nib
Main:
DO
ON task GOSUB Task_0, Task_1, Task_2 ' run current task
task = task + 1 // 3 ' update task pointer
PAUSE 1000
LOOP
END
Task_0:
DEBUG "Running Task 0", CR
RETURN
Task_1:
DEBUG "Running Task 1", CR
RETURN
Task_2:
DEBUG "Running Task 2", CR
RETURN
All
2
NOTE: This example program can be
used with all BS2 models by changing
the $STAMP directive accordingly.