Syntax:
HSerPrintList value1, value2 [, value3 ... ] HSerPrintList [comport], value1, value2 [, value3 ... ]
Note
In the second form, the [comport] square brackets are literal
characters you type exactly as shown. This is different from the
[, value3 … ] further along the first line, which (following the usual
convention in this manual) means that part is optional and is not typed.
Command Availability:
Available anywhere HSerPrint is available.
Enabling Constants:
The same enabling constants as HSerPrint apply.
'USART settings for USART1
#define USART_BAUD_RATE 9600
#define USART_TX_BLOCKING
#define USART_DELAY OFFExplanation:
HSerPrintList sends two or more values in a single statement, instead of
writing one HSerPrint call per value. Each value can be a string,
integer, long, word or byte, and each is sent using the matching typed
HSerPrint call, in the order given, to the default comport. Because the
compiler expands the list into ordinary HSerPrint calls, mixing types in
one statement — a string, then a byte, then a word, and so on — works
exactly as if each value had been sent with its own HSerPrint statement.
HSerPrintList does not send any new line characters. As with HSerPrint,
follow the statement with HSerPrint 13 and HSerPrint 10 if the receiving
terminal needs a new line.
An optional leading [comport] argument sends every value in the list to
that comport instead of the default. comport must be a number or a
defined constant, and a comma must follow the closing ] -
HSerPrintList [2] a, b (no comma) is rejected with a compile error rather
than silently accepted. Internally this passes the comport straight through to
HSerPrint’s own existing comport parameter on each expanded call
(`HSerPrint value, comport), so HSerPrintList [2], a, b is exactly
equivalent to writing HSerPrint a, 2 and HSerPrint b, 2 by hand. This
comport argument is not available on Ser1PrintList, Ser2PrintList or
Ser3PrintList, since a software-serial channel has no comport to select.
Note
The compiler merges a repeated, identical comport setup across
consecutive expanded calls, so HSerPrintList [2], a, b, c only sets the
comport once in the generated code rather than once per value (PIC and AVR
both). This optimisation is automatically disabled for the whole program if
it defines an Interrupt sub, since an interrupt could otherwise fire
between two calls and change the comport for its own purposes without the
compiler being able to see that from this code alone.
Example:
#chip 16F877A, 20
#define USART_BAUD_RATE 9600
#define USART_TX_BLOCKING
#define USART_DELAY OFF
Dim Txt_Heading As String * 12 = "K9AY North"
Dim SignalLevel As Byte = 87
Dim SampleCount As Word = 4213
Do
HSerPrintList "{STAT,", Txt_Heading, ",", SignalLevel, ",", SampleCount, "}", 13, 10 ' <<< the HSerPrintList instruction
Wait 1 s
LoopKey line: the single HSerPrintList call above sends a string literal, a
string variable, another string literal, a byte, another string literal, a
word, a closing brace and a CR/LF pair — nine values in total — as nine
typed HSerPrint calls, without writing any of them out by hand.
Example with a comport:
#chip 16F877A, 20
#define USART_BAUD_RATE 9600
#define USART_TX_BLOCKING
#define USART_DELAY OFF
#define MyPort 2
Dim SignalLevel As Byte = 87
Dim SampleCount As Word = 4213
Do
HSerPrintList [MyPort], SignalLevel, ",", SampleCount, 13, 10 ' <<< sends to MyPort (2)
Wait 1 s
LoopKey line: every value in the HSerPrintList call is sent to comport 2 (via
the MyPort constant), instead of the default comport.
See Also:
- HSerPrint — sending a single value, or a value to a specific comport
- HSerSendBytes — sending 2 to 16 raw bytes in one call, rather than typed values
- Ser1PrintList, Ser2PrintList, Ser3PrintList — the same mixed-type list, on a software-serial channel

