DEBUG - BASIC Stamp Command Reference
Page 100 • BASIC Stamp Programming Manual 2.0b • www.parallaxinc.com
Expressions are allowed within the DEBUG command arguments as well.
In the above code, DEBUG DEC x+25 would yield "95" and DEBUG
DEC x*10/2-3 would yield "322".
Formatter Description
? Displays "symbol = x" + carriage return; where x is a number.
Default format is decimal, but may be combined with number
formatters below (ex: bin ? x to display "x = binary_number").
ASC ? Displays "symbol = 'x'" + carriage return; where x is an ASCII
character.
DEC{1..5} Decimal text, optionally fixed for 1 to 5 digits.
SDEC{1..5} Signed decimal text, optionally fixed for 1 to 5 digits.
HEX{1..4} Hexadecimal text, optionally fixed for 1 to 4 digits.
SHEX{1..4} Signed hex text, optionally fixed for 1 to 4 digits.
IHEX{1..4} Indicated hex text ($ prefix; ex.: $7A3), optionally fixed for 1 to 4
digits.
ISHEX{1..4} Indicated, signed hex text, optionally fixed for 1 to 4 digits.
BIN{1..16} Binary text, optionally fixed for 1 to 16 digits.
SBIN{1..16} Signed binary text, optionally fixed for 1 to 16 digits.
IBIN{1..16} Indicated binary text (% prefix; ex.: %1001), optionally fixed for 1
to 16 digits.
ISBIN{1..16} Indicated, signed binary text, optionally fixed for 1 to 16 digits.
STR bytearray ASCII string from bytearray until byte = 0.
STR bytearray\n ASCII string consisting of n bytes from bytearray.
REP byte\n Display ASCII character n times.
As seen in Table 6.3, special versions of the DEC, HEX and BIN formatters
allow for the display of indicated, signed and fixed-width numbers. The
term "indicated" simply means that a special symbol is displayed, before
the number, indicating what number system it belongs to. For example,
x VAR BYTE
x = 65
DEBUG HEX x ' Show hexadecimal value of x.
displays "41" (65, in decimal, is 41, in hexadecimal). You might see a
problem here… unless you knew the number was supposed to be
hexadecimal, you might think it was 41, in decimal… a totally different
number. To help avoid this, use the IHEX formatter (the "I" stands for
indicated). Changing the DEBUG line to read: DEBUG IHEX x would
print "$41" on the screen. A similar formatter for binary also exists, IBIN,
which prints a "%" before the number.
DISPLAYING
INDICATED" NUMBERS.
E
XPRESSIONS IN DEBUG
Table 5.5: DEBUG Formatters.