Parallax BASIC Stamp 2e Programming Manual page 105

Table of Contents

Advertisement

D
(
ISPLAYING STRINGS
BYTE ARRAYS
V
-
.
ARIABLE
WIDTH STRINGS
5: BASIC Stamp Command Reference - DEBUG
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
Unsigned: 65471
$FFBF
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.
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.
BASIC Stamp Programming Manual 2.0c • www.parallaxinc.com • Page 103
-%0000000001000001
%1111111110111111
NOTE:
If your byte array

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?

Table of Contents