BASIC stamp manual v2.2

DEBUG – BASIC Stamp Command Reference
Page 166 BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com
displays "00165". Notice that leading zeros? The display is "fixed" to 5
digits, no more and no less. Any unused digits will be filled with zeros.
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 5.11) 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
DISPLAYING STRINGS (BYTE ARRAYS).
V
ARIABLE-WIDTH STRINGS.