> Am piqued as to how you've used CF to do it tho- surely not
> using HTML?
EAN-8 is easy using 2 functions I wrote...
<cffunction name="generateCheckDigit" access="remote" returntype="string">
<cfargument name="barcode" type="numeric" required="yes">
<cfargument name="complete" type="boolean" required="no"
default="false">
<cfscript>
if (len(trim(barcode)) GT 7) {
return "Error: To many digits";
} else {
internal.barcode = numberFormat(barcode,"0000000");
internal.sum = 0;
for (i=1; i lte 7; i=i+1) {
if (i mod 2 is 0) { positionMultiple = 1; }
else { positionMultiple = 3; }
internal.sum = internal.sum +
mid(internal.barcode,i,1) * positionMultiple;
}
if (complete) {
return internal.barcode & right(10 -
(internal.sum mod 10),1);
} else {
return right(10 - (internal.sum mod 10),1);
}
}
</cfscript>
</cffunction>
<cffunction name="generateBarcode" access="remote" returntype="string">
<cfargument name="barcode" type="numeric" required="yes">
<cfscript>
encodethis = trim(barcode);
encodethis = "00000000" & encodethis;
encodethis = right(encodethis,8);
barcode = "[";
barcode = barcode & chr(asc("A")+mid(encodethis,1,1));
barcode = barcode & chr(asc("A")+mid(encodethis,2,1));
barcode = barcode & chr(asc("A")+mid(encodethis,3,1));
barcode = barcode & chr(asc("A")+mid(encodethis,4,1));
barcode = barcode & "|";
barcode = barcode & mid(encodethis,5,1);
barcode = barcode & mid(encodethis,6,1);
barcode = barcode & mid(encodethis,7,1);
barcode = barcode & mid(encodethis,8,1);
barcode = barcode & "]";
return barcode;
</cfscript>
</cffunction>
I have stripped out comments and hints to reduce clutter, but basically the
first one calculates a check digit for you and the second creates the
characters for display by the font. As you can see the right hand digits are
made up of simply 0,1,2,3,4.... And the left hand digits are simply
A,B,C,D..... (both of these character sets are font dependent of course.)
In this way if you wanted to encode a stock quantity in a box, say 25 for
example, you can use...
#generateBarcode(generateCheckDigit(25,true))#
And this will return the character string "[AAAA|0253]" where [, | and ] are
the start, centre and end characters and the AAAA0253 are the 8 digits of
the barcode.
EAN-13 is more complicated as the left hand digits are made up of two
diferent character sets for odd and even parity.
--
James Smith - IT Director
uWish Ltd - http://www.uWish.co.uk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7
Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs
http:http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU
Archive:
http://www.houseoffusion.com/groups/CF-Community/message.cfm/messageid:225510
Subscription: http://www.houseoffusion.com/groups/CF-Community/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.5