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. If the receiving
terminal needs a new line, end the list with a string holding a carriage return
and a line feed, written with the \r and \n escape sequences -
HSerPrintList "Count: ", xx, "\r\n" - or follow the statement with
HSerPrintCRLF. See Dim for the string escape sequences.
A number in the list is sent as its digits, as HSerPrint sends it: 13, 10
sends the four characters 1310, not a carriage return and a line feed.
The list may also be written in brackets, as a sub call may be:
HSerPrintList ("d", inchar, ":") and HSerPrintList("d", inchar, ":") are the
same as HSerPrintList "d", inchar, ":". The brackets are taken off only when
they hold the whole list, so HSerPrintList (a + 1) * 2, b sends two values,
(a + 1) * 2 and then b. A leading [comport] goes inside the brackets:
HSerPrintList ([2], a, b).
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, "}\r\n" ' <<< 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, and a closing brace followed by a carriage return and a line feed
("}\r\n") — seven values in total — as seven 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, "\r\n" ' <<< 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

