Specifications

BASIC Stamp II
Parallax, Inc. • BASIC Stamp Programming Manual 1.8 • Page 253
2
Debug
DEBUG
outputData{,outputData...}
Display variables and messages on the PC screen within the STAMP2
host program.
OutputData
consists of one or more of the following: text strings,
variables, constants, expressions, formatting modifiers, and
control characters
Explanation
Debug provides a convenient way for your programs to send messages
to the PC screen during programming. The name Debug suggests its
most popular use—debugging programs by showing you the value of
a variable or expression, or by indicating what portion of a program is
currently executing. Debug is also a great way to rehearse program-
ming techniques. Throughout this instruction guide, we use Debug to
give you immediate feedback on the effects of instructions. Let’s look at
some examples:
DEBUG "Hello World!" ' Test message.
After you press ALT-R to download this one-line program to the BS2,
the STAMP2 host software will put a Debug window on your PC screen
and wait for a response. A moment later, the phrase "Hello World!" will
appear. Pressing any key other than space eliminates the Debug win-
dow. Your program keeps executing after the screen is gone, but you
can’t see the Debug data. Another example:
x var byte: x = 65
DEBUG dec x ' Show decimal value of x.
Since x = 65, the Debug window would display “65.” In addition to
decimal, Debug can display values in hexidecimal and binary. See table
I-1 for a complete list of Debug prefixes.
Suppose that your program contained several Debug instructions
showing the contents of different variables. You would want some way
to tell them apart. Just add a question mark (?) as follows:
x var byte: x = 65
DEBUG dec ? x ' Show decimal value of x with label "x = "
Now Debug displays “x = 65.” Debug works with expressions, too: