Skip to content

Formatting String Input Parameters

Strings used as input parameters to method and property commands can be formatted in a variety of ways. This topic explains the formatting options available for scalar parameters as well for string arrays.

Strings used as input parameters have format specifications of the following general form:

%[flags] [width] [.precision] [delimiter] [q | Q] s

ModifierInterpretation
flags -, 0Controls justification and padding of the output, as follows:
- - left aligns the result with the given field width.
0 - pads with zeros until the width is reached. If 0 and - appear together, the 0 is ignored.
widthMinimum field width of the output string.
precisionMaximum number of characters to send.
delimiterThe parameter must be an array of strings. The elements of the string array are sent to the device with the specified delimiter between each element. The following delimiters are supported. Note that the enclosing parentheses are not required for comma-separated lists:
, or (,) - comma-separated list
(;) - semicolon-separated list
(:) - colon-separated list
(s) - space-separated list
(t) - tab-separated list
(r) - carriage return-separated list
(n) - linefeed-separated list
qThe string is formatted with enclosing single quotes (').
QThe string is formatted with enclosing double quotes (").
Parameter TagData Sent to Device
{Name:%15s}\s\s\s\sHello World Minimum width is 15. Pad to the left.
{Name:%-15s}Hello World\s\s\s\s Left justify. Pad to the right.
{Name:%.5s}Hello Precision specifies maximum length.
{Name:%qs}'Hello World' Enclose in single quotes.
{Name:%15qs}\s\s\s\s'Hello World' Padding is applied outside of the quotes.
{Name:%-15Qs}"Hello World\s\s\s\s" Left justify. Enclose in double quotes.
{NamesArray:%,5qs}'\s\sone','\s\stwo','three','\sfour' Field width and quotes applied to each element.
{NamesArray:%(:)Qs}"one":"two":"three":"four" Colon-separated list. Each element enclosed in double quotes.