BASIC stamp manual v2.2

SEROUT – BASIC Stamp Command Reference
Page 422 BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com
indicated number of digits (in the case of the fixed length formatters) is
translated.
All BS2 models also have special formatters for outputting a string of
characters, and repeated characters. See Table 5.111 for a list of these
special formatters.
Conversion
Formatter
Type of Number Notes
DEC{1..5} Decimal, optionally fixed to 1 – 5 digits 1
SDEC{1..5} Signed decimal, optionally fixed to 1 – 5 digits 1,2
HEX{1..4} Hexadecimal, optionally fixed to 1 – 4 digits 1,3
SHEX{1..4} Signed hexadecimal, optionally fixed to 1 – 4 digits 1,2
IHEX{1..4} Indicated hexadecimal, optionally fixed to 1 – 4 digits ($ prefix) 1
ISHEX{1..4}
Signed, indicated hexadecimal, optionally fixed to 1 – 4 digits
($ prefix)
1,2
BIN{1..16} Binary, optionally fixed to 1 – 16 digits 1
SBIN{1..16} Signed binary, optionally fixed to 1 – 16 digits 1,2
IBIN{1..16} Indicated binary, optionally fixed to 1 – 16 digits (% prefix) 1
ISBIN{1..16} Signed, indicated binary, optionally fixed to 1 – 16 digits (% prefix) 1,2
Table 5.110: Conversion
Formatters for all BS2 models.
1 Fixed-digit formatters like DEC4 will pad the number with leading 0s if necessary; ex:
DEC4 65 sends 0065. If a number is larger than the specified number of digits, the
leading digits will be dropped; ex: DEC4 56422 sends 6422.
2 Signed modifiers work under two's complement rules.
3 The HEX modifier can be used for BCD to Decimal Conversion. See “Hex to BCD
Conversion” on page 97.
Special Formatter Action
?
Displays "symbol = x' + carriage return; where x is a number.
Default format is decimal, but may be combined with conversion
formatters (ex: BIN ? x to display "x = binary_number").
ASC ?
Displays "symbol = 'x'" + carriage return; where x is an ASCII
character.
STR ByteArray {\L}
Send character string from an array. The optional \L argument
can be used to limit the output to L characters, otherwise,
characters will be sent up to the first byte equal to 0 or the end
of RAM space is reached.
REP Byte \L
Send a string consisting of Byte repeated L times
(ex: REP "X"\10 sends "XXXXXXXXXX").
Table 5.111: Special Formatters
for all BS2 models.
The string formatter is useful for transmitting a string of characters from a
byte array variable. A string of characters is a set of characters that are
arranged or accessed in a certain order. The characters "ABC" could be
stored in a string with the "A" first, followed by the "B" and then followed
by the "C." A byte array is a similar concept to a string; it contains data
that is arranged in a certain order. Each of the elements in an array is the
THE STR (STRING) FORMATTER.
All
2