28125 Parallax Inc, 28125 Datasheet - Page 155

TEXT ROBOTICS

28125

Manufacturer Part Number
28125
Description
TEXT ROBOTICS
Manufacturer
Parallax Inc
Datasheet

Specifications of 28125

Title
Robotics with the Boe-Bot
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
Figure 4-5 shows part of a PBASIC program that contains a subroutine call and a
subroutine. The subroutine call is the
subroutine is everything from the
Here’s how it works. When the program gets to the
it looks for the
the
down line by line from the label, so you’ll see the message “Command in subroutine” in
your Debug Terminal.
program gets to the
command immediately after the
that displays the message “After subroutine”.
Example Program – OneSubroutine.bs2
' Robotics with the Boe-Bot - OneSubroutine.bs2
' This program demonstrates a simple subroutine call.
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Before subroutine",CR
PAUSE 1000
GOSUB My_Subroutine
DEBUG "After subroutine", CR
END
My_Subroutine:
My_Subroutine:
2
Enter, save, and run OneSubroutine.bs2
My_Subroutine:
DO
LOOP
My_Subroutine:
DEBUG "Before subroutine",CR
PAUSE 1000
GOSUB My_Subroutine
DEBUG "After subroutine", CR
PAUSE 1000
DEBUG "Command in subroutine", CR
PAUSE 1000
RETURN
RETURN
label and starts executing commands. The program keeps going
PAUSE 1000
command, arrow (2) shows how it jumps back to the
GOSUB
My_Subroutine:
label. As shown by arrow (1), the program jumps to
GOSUB My_Subroutine
command. In this case, it’s a
causes a one second pause. Then, when the
label through the
GOSUB My_Subroutine
1
command. The actual
RETURN
DEBUG
Figure 4-5
Subroutine
Basics
command.
command,
command

Related parts for 28125