Script to simulate changing an Increment Decrement field's "By Value" property
Description
The By Value of an Increment Decrement (Incr/Decr) field is the amount the field's value will either increase or decrease for each subsequent label printed when printing more than one label.
A requirement may exist to allow for the By Value of a Incr/Decr field to be sent in a drop file, as the value may vary.
How to simulate changing the "By Value" property of an Increment Decrement Field.
While you cannot actually alter the By Value property directly by specifying a value in a drop file, you can have multiple non-printing Incr/Decr fields stacked one on top of another on the label, each with a different By Value setting. You can then use a script to turn the correct one on to print based upon a passed value in the drop file.
Sample
In the sample label file below, there are three non printing Incr/Decr fields as follows;
Script For Multiple IncrDecr Inc Values.lwl
Inc1 - Field will increment by 1
Inc2 - Field will increment by 2
Inc3 - Field will increment by 3
All three of these fields are stacked one on top of another at the same spot on the label.
There is also a field on the label called Inc. A value for this field will be sent in the drop file and will be used to determine which of the three Incr/Decr fields to turn printing on for. The script is as follows;
//define variables
var inc = String(label.fields.field.(@name == 'Inc').@data);
//define if-else statement
if (inc=="1")
{
//print field
label.fields.field.(@name =='Inc1').@printingField = true
}
else if (inc=="2")
{
//print field
label.fields.field.(@name =='Inc2').@printingField = true
}
else if (inc=="3")
{
//print field
label.fields.field.(@name =='Inc3').@printingField = true
}
By sending an Inc value of "1", the Inc1 field will have printing turned on. By sending an Inc value of "2", the Inc2 field will have printing turned on, etc.
Article Number
2016049
Versions
Loftware Label A label is a design area on the computer screen where a label format is created or edited. Manager / Loftware Print Server versions 9.5.2.0 - 11.1