Jump to content

Label Template Syntax: Difference between revisions

From Commander4j
Created page with "See Zebra ZPL Label for a label designed for a Zebra Pallet Label or Intermec IPL Label for a label designed using the IPL language. For explanation of it's format see below. DEFINE BARCODE BARCODE1 02<PADLEFT(<*EAN*>,14,0)>20<PADLEFT(<*VARIANT*>,2,0)>15<EXPIRYDATE(yy)><EXPIRYDATE(MM)><EXPIRYDATE(dd)>37<*QUANTITY^0000*>^10<*BATCH_NUMBER*> This line is used to create a barcode variable. You may wonder why you cannot use the same string to print the label and..."
 
Updated by push_wiki.py
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
See [[Zebra ZPL Label]] for a label designed for a Zebra Pallet Label or [[Intermec IPL Label]] for a label designed using the IPL language. For explanation of it's format see below.
'''Label Template Syntax''' describes how a label template file is put together. A template is the file that Commander4j, and [[AutoLab4j]], send to a barcode printer after filling in the values for a pallet or case. If you only want to make a small change to an existing label, [[Changing a Label]] is a gentler starting point; this page is the reference behind it.
   
 
  DEFINE BARCODE BARCODE1  02<PADLEFT(<*EAN*>,14,0)>20<PADLEFT(<*VARIANT*>,2,0)>15<EXPIRYDATE(yy)><EXPIRYDATE(MM)><EXPIRYDATE(dd)>37<*QUANTITY^0000*>^10<*BATCH_NUMBER*>
== The idea in one paragraph ==
 
A label template is a plain text file in the <code>labels</code> folder. Most of it is written in the printer's own language, ZPL for Zebra or IPL for Intermec, exactly as you would find in the printer's programming guide. Wherever a value should change from one pallet to the next, the template contains a placeholder instead of a fixed value. When a label is printed, Commander4j reads the template, swaps every placeholder for the real value, works out the barcode code-set switching, and sends the result to the printer as one stream of text. The printer never sees the placeholders.
 
Two worked examples are on this wiki: [[Zebra ZPL Label]] and [[Intermec IPL Label]].
 
== What a template contains ==
 
{| class="wikitable"
! Kind of line !! Looks like !! What happens to it
|-
| Comment || <code>/* Product description */</code> || Any line that starts with <code>/*</code> is dropped before the label is sent. Use comments to label each block. Putting <code>/*</code> at the start of a printer command is a handy way to switch that line off without deleting it.
|-
| Printer command || <code>^FO80,1070^A0N,50,50^FDDESCRIPTION^FS</code> || Sent to the printer unchanged, apart from placeholders and functions inside it.
|-
| Placeholder || <code><nowiki><*DESCRIPTION*></nowiki></code> || Replaced by the value of that field. The available names are listed on [[Label Fields]].
|-
| Function || <code><nowiki><PADLEFT(<*EAN*>,14,0)></nowiki></code> || Formats a value before it is printed. Functions can be nested; the innermost runs first. See [[Label Function Syntax]].
|-
| Directive || <code>DEFINE BARCODE BARCODE2 00<nowiki><*SSCC*></nowiki></code> || An instruction to Commander4j itself. Directives are read and removed; they are never sent to the printer. They are described below.
|}
 
Blank lines are ignored and leading spaces are trimmed, so the file can be laid out for readability.
 
== Placeholders ==
 
A placeholder is a field name between <code><nowiki><*</nowiki></code> and <code><nowiki>*></nowiki></code>:
 
  <*SSCC*>  <*QUANTITY*>  <*DESCRIPTION*>
 
Dates and numbers accept a format after a <code>^</code> character:
 
  <*DATE_OF_MANUFACTURE^dd/MM/yyyy*>
<*QUANTITY^000000*>
 
Without a format a date prints as yyyy-MM-dd and a number is padded to four digits. The format is ignored for text fields.
 
Three rules worth knowing:
 
* A placeholder whose name is not available on this screen prints the name followed by '''not found!''' so the mistake is visible on the label.
* Round brackets inside a text value are printed as curly braces, because round brackets have a meaning in function syntax.
* Names defined with DEFINE BARCODE take precedence over database fields of the same name.
 
== Directives ==
 
Directives are lines that Commander4j acts on and removes. They are normally placed at the top of the file. A directive must be the first thing on its line.
 
{| class="wikitable"
! Directive !! Purpose
|-
| <code>DEFINE BARCODE name value</code> || Creates a barcode variable. Explained in detail below.
|-
| <code>DEFINE BARCODE COUNT_MODE ZPL</code> || Tells Commander4j to send the label once and let the printer make the copies. Pair it with <code><nowiki>^PQ<*ZPL_LABEL_COUNT*></nowiki></code> in the template, which prints the number of copies the operator asked for. Without this directive Commander4j sends the whole label once per copy and ZPL_LABEL_COUNT is always 1.
|-
| <code>SUPPRESS EOL</code> || Joins all the lines together with no line endings. Needed by some printer languages.
|-
| <code>SUPPRESS UNICODE</code> || Stops accented and other non-ASCII characters being converted to the <code>_XX</code> hex escape form that Zebra printers read after <code>^FH</code>. Use it only for printers that do not use this escape form.
|-
| <code>SUPPRESS ASCII ENCODE</code> || Normally the control-character names <code>&lt;STX&gt;</code>, <code>&lt;ETX&gt;</code>, <code>&lt;ESC&gt;</code> and so on are translated into the real control characters before the label is sent. With this directive they are sent to the device exactly as written. When writing a template for a non-Zebra printer, copy the directives from the shipped template for that printer make rather than working them out from scratch.
|}
 
== DEFINE BARCODE in detail ==
 
This is the part of a template that needs the most care, and it only matters when you are changing what is encoded in a barcode. For a caption or date change you can leave it alone.
 
DEFINE BARCODE BARCODE1  02<PADLEFT(<*EAN*>,14,0)>20<PADLEFT(<*VARIANT*>,2,0)>15<EXPIRYDATE(yy)><EXPIRYDATE(MM)><EXPIRYDATE(dd)>37<*QUANTITY^0000*>^10<*BATCH_NUMBER*>


This line is used to create a barcode variable. You may wonder why you cannot use the same string to print the label and skip this step. The reason that using the Zebra ZPL language, when encoding in the Code 128 barcode symbology you need to determine what type of data is in the barcode. Numeric data can be compressed when it appears in pairs (even number) of characters. Alphabetic characters have to use a different encoding.
This line is used to create a barcode variable. You may wonder why you cannot use the same string to print the label and skip this step. The reason that using the Zebra ZPL language, when encoding in the Code 128 barcode symbology you need to determine what type of data is in the barcode. Numeric data can be compressed when it appears in pairs (even number) of characters. Alphabetic characters have to use a different encoding.
Line 32: Line 97:


This is used to indicate the end of the DEFINE section of the label.
This is used to indicate the end of the DEFINE section of the label.
Because a DEFINE BARCODE line is split on spaces, the value must not contain a space.
== See also ==
* [[Label Layouts]]
* [[Changing a Label]]
* [[Label Fields]]
* [[Label Function Syntax]]
* [[Zebra ZPL Label]]
* [[Intermec IPL Label]]
* [[Useful Information]]
[[Category:Commander4j]]
[[Category:AutoLab4j]]

Latest revision as of 10:26, 15 October 2026

Label Template Syntax describes how a label template file is put together. A template is the file that Commander4j, and AutoLab4j, send to a barcode printer after filling in the values for a pallet or case. If you only want to make a small change to an existing label, Changing a Label is a gentler starting point; this page is the reference behind it.

The idea in one paragraph

A label template is a plain text file in the labels folder. Most of it is written in the printer's own language, ZPL for Zebra or IPL for Intermec, exactly as you would find in the printer's programming guide. Wherever a value should change from one pallet to the next, the template contains a placeholder instead of a fixed value. When a label is printed, Commander4j reads the template, swaps every placeholder for the real value, works out the barcode code-set switching, and sends the result to the printer as one stream of text. The printer never sees the placeholders.

Two worked examples are on this wiki: Zebra ZPL Label and Intermec IPL Label.

What a template contains

Kind of line Looks like What happens to it
Comment /* Product description */ Any line that starts with /* is dropped before the label is sent. Use comments to label each block. Putting /* at the start of a printer command is a handy way to switch that line off without deleting it.
Printer command ^FO80,1070^A0N,50,50^FDDESCRIPTION^FS Sent to the printer unchanged, apart from placeholders and functions inside it.
Placeholder <*DESCRIPTION*> Replaced by the value of that field. The available names are listed on Label Fields.
Function <PADLEFT(<*EAN*>,14,0)> Formats a value before it is printed. Functions can be nested; the innermost runs first. See Label Function Syntax.
Directive DEFINE BARCODE BARCODE2 00<*SSCC*> An instruction to Commander4j itself. Directives are read and removed; they are never sent to the printer. They are described below.

Blank lines are ignored and leading spaces are trimmed, so the file can be laid out for readability.

Placeholders

A placeholder is a field name between <* and *>:

<*SSCC*>  <*QUANTITY*>  <*DESCRIPTION*>

Dates and numbers accept a format after a ^ character:

<*DATE_OF_MANUFACTURE^dd/MM/yyyy*>
<*QUANTITY^000000*>

Without a format a date prints as yyyy-MM-dd and a number is padded to four digits. The format is ignored for text fields.

Three rules worth knowing:

  • A placeholder whose name is not available on this screen prints the name followed by not found! so the mistake is visible on the label.
  • Round brackets inside a text value are printed as curly braces, because round brackets have a meaning in function syntax.
  • Names defined with DEFINE BARCODE take precedence over database fields of the same name.

Directives

Directives are lines that Commander4j acts on and removes. They are normally placed at the top of the file. A directive must be the first thing on its line.

Directive Purpose
DEFINE BARCODE name value Creates a barcode variable. Explained in detail below.
DEFINE BARCODE COUNT_MODE ZPL Tells Commander4j to send the label once and let the printer make the copies. Pair it with ^PQ<*ZPL_LABEL_COUNT*> in the template, which prints the number of copies the operator asked for. Without this directive Commander4j sends the whole label once per copy and ZPL_LABEL_COUNT is always 1.
SUPPRESS EOL Joins all the lines together with no line endings. Needed by some printer languages.
SUPPRESS UNICODE Stops accented and other non-ASCII characters being converted to the _XX hex escape form that Zebra printers read after ^FH. Use it only for printers that do not use this escape form.
SUPPRESS ASCII ENCODE Normally the control-character names <STX>, <ETX>, <ESC> and so on are translated into the real control characters before the label is sent. With this directive they are sent to the device exactly as written. When writing a template for a non-Zebra printer, copy the directives from the shipped template for that printer make rather than working them out from scratch.

DEFINE BARCODE in detail

This is the part of a template that needs the most care, and it only matters when you are changing what is encoded in a barcode. For a caption or date change you can leave it alone.

DEFINE BARCODE BARCODE1 02<PADLEFT(<*EAN*>,14,0)>20<PADLEFT(<*VARIANT*>,2,0)>15<EXPIRYDATE(yy)><EXPIRYDATE(MM)><EXPIRYDATE(dd)>37<*QUANTITY^0000*>^10<*BATCH_NUMBER*>

This line is used to create a barcode variable. You may wonder why you cannot use the same string to print the label and skip this step. The reason that using the Zebra ZPL language, when encoding in the Code 128 barcode symbology you need to determine what type of data is in the barcode. Numeric data can be compressed when it appears in pairs (even number) of characters. Alphabetic characters have to use a different encoding.

So - the purpose of the DEFINE BARCODE directive it to let Commander4j look at the complete barcode string in advance and insert the appropriate commands to switch Code Sets before the data is sent to the barcode printer.

The Printer Commands which are used to switch between modes are also defined below.

DEFINE BARCODE BARCODE2   00<*SSCC*>

This is another example of a barcode variable.

DEFINE BARCODE FNC1       >8

FNC1 is required only at the end of variable length data section. It is not required as the last character in the bar code.

DEFINE BARCODE CODEA      >9

Subset A supports numbers, upper-case letters, and control characters, such as tab and new-line

DEFINE BARCODE CODEB      >6

Subset B supports numbers, upper- and lower-case letters and some additional characters.

DEFINE BARCODE CODEC      >;

Subset C supports numbers only. It must have an even number of digits.

DEFINE BARCODE END        *END*

This is used to indicate the end of the DEFINE section of the label.

Because a DEFINE BARCODE line is split on spaces, the value must not contain a space.

See also