5: BASIC Stamp Command Reference - DEBUG
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 103
Using DEC4 in the same code would display "0165". DEC3 would display
"165". What would happen if we used DEC2? Regardless of the number,
the BASIC Stamp will ensure that it is always the exact number of digits
you specified. In this case, it would truncate the "1" and only display "65".
Using the fixed-width version of the formatters in the Signed/Unsigned
code above, may result in the following code:
x VAR WORD
x = -65
DEBUG "Signed: ", SDEC5 x, " ", ISHEX4 x, " ", ISBIN16 x, CR
DEBUG "Unsigned: ", DEC5 x, " ", IHEX4 x, " ", IBIN16 x
and displays:
Signed: -00065 -$0041 -%0000000001000001
Unsigned: 65471 $FFBF %1111111110111111
Note: The columns don't line up exactly (due to the extra "sign" characters
in the first row), but it certainly looks better than the alternative.
If you have a string of characters to display (a byte array), you can use the
STR formatter to do so. The STR formatter has two forms (as shown in
Table 6.3) for variable-width and fixed-width data. The example below is
the variable-width form.
x VAR BYTE(5)
x(0) = "A"
x(1) = "B"
x(2) = "C"
x(3) = "D"
x(4) = 0
DEBUG STR x
This code displays "ABCD" on the screen. In this form, the STR formatter
displays each character contained in the byte array until it finds a
character that is equal to 0 (value 0, not "0"). This is convenient for use
with the SERIN command's STR formatter, which appends 0's to the end
of variable-width character string inputs. NOTE: If your byte array
doesn't end with 0, the BASIC Stamp will read and output all RAM
register contents until it finds a 0 or until it cycles through all RAM
locations.
D
ISPLAYING STRINGS
(
BYTE ARRAYS
).
V
ARIABLE
-
WIDTH STRINGS
.
Summary of Contents for BASIC Stamp 2e
Page 1: ...BASIC Stamp Programming Manual Version 2 0c...
Page 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...