BASIC stamp manual v2.2
DEBUG – BASIC Stamp Command Reference
Page 162 • BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com
BASIC Stamp 2, 2e, 2sx, 2p, 2pe, and 2px Formatting
On the all BASIC Stamp models except the BS1, the DEBUG command, by
default, displays everything as ASCII characters. What if you want to
display a number? You might think the following example would do this:
x VAR Byte
x = 65
DEBUG x ' Try to show decimal value of x
Since we set x equal to 65 (in line 2), you might expect the DEBUG line to
display “65” on the screen. Instead of “65”, however, you’ll see the letter
“A” if you run this example. The problem is that we never told the BASIC
Stamp how to output x, and it defaults to ASCII (the ASCII character at
position 65 is “A”). Instead, we need to tell it to display the “decimal
form” of the number in x. We can do this by using the decimal formatter
(DEC) before the variable. The example below will display “65” on the
screen.
x VAR Byte
x = 65
DEBUG DEC x ' Show decimal value of x
In addition to decimal (DEC), DEBUG can display numbers in
hexadecimal (HEX) and binary (BIN). See Table 5.11 and Table 5.12 for a
complete list of formatters.
Expressions are allowed within the DEBUG command arguments as well.
In the above code, DEBUG DEC x+25 would yield "90" and DEBUG
DEC x*10/2-3 would yield "322".
DISPLAYING ASCII CHARACTERS.
D
ISPLAYING DECIMAL NUMBERS.
All
2
DISPLAYING HEXADECIMAL AND
BINARY NUMBERS.
E
XPRESSIONS IN DEBUG
COMMANDS.