OL Learn

Datamatrix for duplex/simplex and commingled jobs

Just in case somebody needs it:

Requirement was a datamatrix code for an inserter with following specifications:
7 digits

  • digit 1: collect / insert (0=collect sheets, 1=insert, end of collection)
  • digit 2-3: sequence over the whole job starting from 00, ending at 99, starting over at 00, thus ensuring that no document is missing.
  • digit 4: add product from feeder 2
  • digit 5: add product from feeder 3
  • digit 6: add product from feeder 4
  • digit 7: offset envelope after insertion (for separating ZIP codes or countries)
  • digit 8: divert

Code for Output Creation Setting (Additional Barcode):

${(sheet.nr == document.count.sheets) ? '1': '0';}${(sheet.duplex) ? ("00" + (page.sequence.job/2-.5)).slice(-2) : ("00" + (page.sequence.job - 1)).slice(-2);}${(document.metadata.Feeder1 == '1' ) ? '1':'0';}${(document.metadata.Feeder2 == '1' ) ? '1':'0';}${(document.metadata.Feeder3 == '1' ) ? '1':'0';}${(document.metadata.Separate == '1' ) ? '1':'0';}${(document.metadata.Divert == '1' ) ? '1':'0';}

Short explanation of the first two statements:
${(sheet.nr == document.count.sheets) ? ‘1’: ‘0’;} last sheet in dataset is the end of collection

${(sheet.duplex) ? (“00” + (page.sequence.job/2-.5)).slice(-2) : (“00” + page.sequence.job-1).slice(-2);}
if duplex sequence will be half the the number (minus 0.5) with leading "0"es. in simplex just count the pages.

Condition of barcode:

 (page.front) 

so barcode just prints on the front.

not a really nice solution, but it works. Maybe someone has a hint to beautify that code a bit.

Ralf.

strange thing:

sheet .duplex isn’t available if the sheet is simplex, so above doesn’t work with simplex sheets.

That statement not only checks if sheet.duplex contains something but also if it simply exists. If it doesn’t exist or its value is 0, the statement should default to the second expression in the ternary condition. Do you get an error message or something?

if sheet is simplex error throws:

ApplicationException: error evaluating expression ‘(sheet.duplex) ? (“00” + (page.sequence.job/2-.5)).slice(-2) : (“00” + page.sequence.job-1).slice(-2);’

if duplex, everything works

damned, it wasn’t the sheet.duplex but
(“00” + page.sequence.job-1).slice(-2);

should be:

(“00” + (page.sequence.job-1)).slice(-2);

Happens to the best of us… :wink:

indeed, first topic edited., thx Phil