Thread: datamatrix help
View Single Post
  #1  
Old June 1st, 2018, 03:10 PM
Mike Edwards Mike Edwards is offline
Forum n00b
 
Join Date: Mar 2018
Location: Des Moines, IA
Posts: 9
Default datamatrix help

Hi, everybody! First time posting. I've got a problem in getting a properly-formatted Datamatrix barcode to print for use with our intelligent inserter. It has to be of the format X999999SSTT where XX is a string, 999999 is a zero-padded sequence number, SS is a zero-padded number representing the current sheet, and TT is a zero-padded number representing the total sheets being inserted. Here is the code I came up with:

Code:
{
// Rule converted from XML Template "DataMatrix Barcode Rule":
/* The goal here is to generate the proper Datamatrix 2D barcode
 * using the established pattern for our Rival inserter.
 * FusionPro does not have the notion of simplex/duplex, so we
 * have to state up front what that is.
*/
// Choose the following values:
var JobIDseq	    = "INSCODE"; // Standard EDWARDS field name
var TotalSheets	    = "SHEETS"; // Standard EDWARDS field name
var Sides	    = "Simplex"; // Use Duplex here for duplex jobs. Mixed modes are not supported. :p
var EncodingMode    = "ASCII"; 
var PreferredFormat = "0"; 
var PointSize	    = 6; // "Font size (defaults to 10)": SingleLine
var NoFontTag	    = false; 
var Font	    = "IDAutomationDMatrix"; 
var ProcessTilde    = false;

var TotSheets	    = FormatNumber( "00", FieldOrRule( TotalSheets ) );

// For simplex jobs, the current sheet is simply the page number.
// For duplex jobs, we have to do some basic math.
var CurrSheet	    = Sides == "Simplex"
		    ? FormatNumber( "00", FusionPro.Composition.currentPageNumber )
		    : FormatNumber( "00", Math.ceil( FusionPro.Composition.currentPageNumber / 2 ) )
		    ;

var DataToEncode = FieldOrRule( JobIDseq ) + CurrSheet + TotSheets;
return MakeDataMatrixBarcode(
    DataToEncode, 
    ProcessTilde, 
    EncodingMode, 
    PreferredFormat, 
    PointSize, 
    NoFontTag, 
    Font
    );
}
Everything seems to work except for assigning CurrSheet. It appears that FusionPro.Composition.currentPageNumber is not returning the correct value. Either that or I'm using FormatNumber wrong.
Reply With Quote