Skip to content

Formatting Integer Input Parameters

Integers used as input parameters to method and property commands can be formatted in a variety of ways. Scalar integer parameters are formatted as ASCII text and sent to the instrument. Integer arrays can be sent to the instrument in the following formats:

  • An ASCII list of values separated by commas or another specified delimiter.
  • An IEEE 488.2 binary block.
  • A stream of raw binary data.

This topic presents the format specifications for sending data to the device as ASCII text. For detailed information on sending array data as IEEE binary blocks, see the topic Reading and Writing IEEE 488.2 Binary Block Data. For information on sending array data as raw binary, see the topic Reading and Writing Raw Binary Data.

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

%[flags] [488.2 type] [width] [.precision] [delimiter] [d | o | x ]

ModifierInterpretation
flags +, -, 0Controls justification and padding of the output, as follows:
- - left aligns the result with the given field width.
+ - prefixes the output value with a sign (+ or –) if the output value is of a signed type. By default, a sign only appears for negative values.
0 pads with zeros until the specified width is reached. If 0 and - appear together, the 0 is ignored.
488.2 typeThe number is formatted in one of six standard IEEE 488.2 numeric formats. The supported formats are:
@1 - IEEE 488.2 NR1 format (integer without any decimal point). Example: 123
@2 - IEEE 488.2 NR2 format (number with at least one digit after the decimal point). Example: 123.45
@3 - IEEE 488.2 NR3 format (floating-point number in exponential form). Example: 1.2345E-67
@H - IEEE 488.2 hex format. Example: #HAF35B
@Q - IEEE 488.2 octal format. Example: #Q71234
@B - IEEE 488.2 binary format. Example: #B011101001
widthSpecifies the minimum field width of the converted number. If the converted number is shorter than the field width, it will be padded on the left (or on the right if - is present in the flags field. If @H, @Q, and @B is specified as the 488.2 type, then the width includes the #H, #Q, and #B strings, respectively.
precisionMinimum number of digits to send.
delimiterThe parameter must be an array of integers. The elements of the integer 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
typed - number is formatted as a decimal integer.
o - number is formatted as an octal integer.
x - number is formatted as a hex integer.
Parameter TagData Sent to Device
{Count:%-8d}1234\s\s\s\s Left justify. Pad with spaces.
{Count:%8d}\s\s\s\s1234 Right justify. Pad with spaces.
{Count:%08d}00001234 Right justify. Pad with zeroes.
{CountArray:%,d}1,2,3 Comma-separated list.
{CountArray:%(;)d}1;2;3 Semi-colon separated list.
{CountArray:%04,d}0001,0002,0003 Field width specified applies to each element.