^SN - Serialization Data
Makes the current field a counter that steps by a fixed amount for each copy `^PQ` prints.
^SN turns a field into a counter: send one format, ask ^PQ for a hundred
copies, and each copy carries the next number. ^SN replaces ^FD: it supplies
the field data itself, so a serialized field carries no ^FD. The starting value is
both the first number printed and the template for every later number.
Syntax
^SNv,n,zSupport
Every documented parameter renders the same output Labelary produces.
The renderer parses ^SN and uses it as the field's data in place of ^FD. The right-most run of at most twelve digits advances by n once per copy, wraps inside the width of that run, and keeps every character around it. With z set to N the leading zeros of that run print as spaces. ^PQ's replicates argument r sets how many output pages share one value. Measured against Labelary on 2026-08-20. — not pinned by a test
Labelary renders this command.
Parameters
vStarting valueoptional · textThe first value in the sequence, and the field's data, since ^SN stands in for ^FD. The printer indexes at most the twelve right-most digits, and z pads back to the width of that digit run.
- Default
- 1
- Invalid value
- not documented, and we have not measured it. The guide does not state what a starting value with no digits does. The renderer repeats such a value unchanged on every copy, as Labelary does (measured 2026-08-20).
- Test coverage
nIncrementoptional · integerAdded to the value for each further copy. Precede it with a minus sign to count down.
- Default
- 1
- Accepted range
- -999999999999 to 999999999999
- Invalid value
- not documented, and we have not measured it. The guide and Labelary's reference both give the twelve-digit limit, and neither states what happens past it. The renderer wraps the counter inside the width of the digit run, as Labelary does (measured 2026-08-20). An increment that is not a number falls back to 1.
- Test coverage
- No test at the minimum, maximum or one step outside the range.
zLeading-zero flagoptional · Y or NWhether the printer prints the leading zeroes of the starting value. N replaces them with spaces rather than removes them, so the number stays right-aligned in the field's original width. The last zero of an all-zero value always prints.
- Default
- N
- Invalid value
- discarded, and the default applies
- Test coverage
- Values exercised: N. Not exercised: Y. The invalid-value rule is pinned by 1 test.
Y- Print the leading zeroes
N- Suppress the leading zeroes and print spaces instead (default)
Behavior
The value does not have to be a bare number. The guide indexes the right-most run
of consecutive digits, up to twelve of them, so INV-0042 counts on 0042 and
leaves the prefix alone. In a value that ends in a letter, the printer scans right to
left for a digit, and that number advances. A value with no digit repeats
unchanged. A single format can serialize between 100 and 150 fields.
The counter wraps inside the width of its digit run. Measured against Labelary on
2026-08-20: ^SN99,1,Y prints 99, 00, 01, and ^SN01,-1,Y prints 01,
00, 99. A wider run holds the carry, so ^SN0099,1,Y prints 0100. Digits
past the twelfth stand still: ^SN99999999999999,1,Y steps to 99000000000000.
Zero suppression is not truncation. With z set to N, spaces replace the
leading zeroes, so the digits keep their column instead of a shift to the left. The
last zero of an all-zero value always remains. Measured against Labelary on
2026-07-30: ^SN0001,1,N prints three spaces followed by 1, where ^SN0001,1,Y
prints 0001.
^PQ's first argument sets the number of copies. The counter advances only after
every replicate of a serial number prints, which is ^PQ's third argument.
Measured against Labelary on 2026-08-20: ^PQ4,0,2 prints 0001, 0001, 0002,
0002, and the page count stays at four. A replicates value of 0 or an absent
one gives one page per value.
On a real printer, the first label after a media reload repeats the partial label's
serial number, in case that label did not print completely. ^JZ controls it. This
API does not reproduce that, so a paper run can end one number behind the pages the
renderer returned.
Differences from the specification
Example
Three carton labels numbered 0001, 0002 and 0003. ^SN sits where a ^FD would normally go, and ^PQ decides how far the sequence runs:
^XA
^FO40,40^A0N,40,40^FDCARTON^FS
^FO40,110^A0N,60,60^SN0001,1,Y^FS
^PQ3
^XZ
Related commands
^SFSerialization FieldIncrements the current field's data between copies according to a per-character mask.^FDField DataSupplies the text or barcode content of the field.^PQPrint QuantityPrints the label more than once, the one command here that changes how many pages come back.^FNField NumberNumbers a field so a stored format can fill it in later.