Function overview
Prototype
cfCode128 (
pString; pCodeSet )
Parameters
pString string to be converted for use with barcode font
pCodeSet Code128 variant.
Description
Tags:
Format Barcode
composes the final barcode Code128 of symbology A,B or C from a given alphanumeric string.
includes the checksum of the string (modulo 103) as well as start/stop characters.
this CF is meant to be used with barcode font "IDAutomationC128..."
http://www.advancemeants.com/code128fonts/download.htm
automatic switching between variants A,B,C within a single barcode is not yet supported.
pString: string to be used as a barcode.
pCodeSet: "A" or "B" or "C" are expected.
local var $i stores the actual count of loops.
be careful, $i var should not be used in a script running at the same time.
all vars (although locally stored) should be destroyed when the process is done.
author: tammo fornalik / felix hausberner, dbyte solutions, 01.06.2008
changes: 10.01.2009, Code() and Char() are now native functions in FM10, replaced references to CFs which did that job.
Examples
Sample input
cfCode128( "SBM16672_2008_08_25"; "B" )
Sample output
"SBM16672_2008_08_25" as Code128B including checksum and start/stop tags (viewable with IDAutomation Code128 fonts)
Function code
/*
cfCode128 ( pString; pCodeSet )
---use with FM version >= 10---
composes the final barcode Code128 of symbology A,B or C from a given alphanumeric string.
includes the checksum of the string (modulo 103) as well as start/stop characters.
this CF is meant to be used with barcode font "IDAutomationC128..."
http://www.advancemeants.com/code128fonts/download.htm
automatic switching between variants A,B,C within a single barcode is not yet supported.
pString: string to be used as a barcode.
pCodeSet: "A" or "B" or "C" are expected.
local var $i stores the actual count of loops.
be careful, $i var should not be used in a script running at the same time.
all vars (although locally stored) should be destroyed when the process is done.
author: tammo fornalik / felix hausberner, dbyte solutions, 01.06.2008
changes: 10.01.2009, Code() and Char() are now native functions in FM10, replaced references to CFs which did that job.
type: recursive
dependencies: none
call like: cfCode128( "SBM16672_2008_08_25"; "B" )
*/
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> String is empty -> no output
Case( IsEmpty( pString ); ""
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> CodeSet A, B
; pCodeSet = "A" or pCodeSet = "B";
Let(
[
vInitOnce = Case( IsEmpty( $i );
//the following inits are only processed during initial call
Let(
[
$C128_Start = Char( Case( pCodeSet = "A"; 203; pCodeSet = "B"; 204; 0 ) ); //defined by C128 specs
$C128_Stop = Char( 206 ); //defined by C128 specs
$DataToEncode = Trim( pString );
$WeightedTotal = Code( $C128_Start ) -100; //font specific
$C128_CheckDigit = "w"; //font specific, on internal error
$i = 0
]; "" ); //end let
"" ); //end case
$i = $i +1;
//get the value of each character. calculate the WeightedTotal for modulo 103 checksum.
vCurrentChar = Code( Middle( $DataToEncode; $i; 1 ) );
vCurrentVal = Case( vCurrentChar < 135; vCurrentChar -32; vCurrentChar > 134; vCurrentChar -100 );
vCurrentVal = vCurrentVal * $i;
$WeightedTotal = $WeightedTotal + vCurrentVal
];
Case(
$i < Length( $DataToEncode ); cfCode128( $DataToEncode; pCodeSet ); //recursion
Let(
[
//divide the WeightedTotal by 103 and get the remainder, this is the CheckDigitValue
vChkDigitVal = Mod( $WeightedTotal; 103 );
//map CheckDigit to font specific chars
$C128_CheckDigit = Char( Case( vChkDigitVal = 0; 194; vChkDigitVal < 95 and vChkDigitVal > 0; vChkDigitVal +32; vChkDigitVal > 94; vChkDigitVal +100 ) );
$DataToEncode = Substitute ( $DataToEncode; Char( 32 ); Char( 194 ) ); //replace the spaces with the 194 character, font specific
vPrintableString = $C128_Start & $DataToEncode & $C128_CheckDigit & $C128_Stop;
$C128_Start=""; $C128_Stop=""; $DataToEncode=""; $C128_CheckDigit=""; $WeightedTotal=""; $i="" //kill vars
]; vPrintableString ) //end let
) //end case
) //end let
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> CodeSet C
; pCodeSet = "C";
Let(
[
vInitOnce = Case( IsEmpty( $i );
Let(
[
$C128_Start = Char( 205 );
$C128_Stop = Char( 206 );
$DataToEncode = Filter( pString ; "0123456789" );
vCountOfDigitsIsOdd = Mod( Length( $DataToEncode ); 2 ) = 1;
$DataToEncode = Case( vCountOfDigitsIsOdd; "0"; "" ) & $DataToEncode;
$DataToPrint = "";
$WeightValue = 0;
$WeightedTotal = Code( $C128_Start ) -100;
$C128_CheckDigit = "w";
$i = -1 //...so the first used value will be 1
]; "" ); //end let
"" ); //end case
$i = $i +2;
$WeightValue = $WeightValue +1;
vCurrentChar = Middle( $DataToEncode; $i; 2 );
$DataToPrint = $DataToPrint & Case( vCurrentChar < 95 and vCurrentChar > 0; Char( vCurrentChar +32 ); vCurrentChar > 94; Char( vCurrentChar +100 ); vCurrentChar = 0; Char( 194 ) );
$WeightedTotal = $WeightedTotal + (vCurrentChar * $WeightValue)
];
Case(
$i < Length( $DataToEncode ); cfCode128( $DataToEncode; pCodeSet ); //recursion
Let(
[
vChkDigitVal = Mod( $WeightedTotal; 103 );
$C128_CheckDigit = Char( Case( vChkDigitVal < 95 and vChkDigitVal > 0; vChkDigitVal +32; vChkDigitVal > 94; vChkDigitVal +100; vChkDigitVal = 0; 194 ) );
vPrintableString = $C128_Start & $DataToPrint & $C128_CheckDigit & $C128_Stop;
$C128_Start=""; $C128_Stop=""; $DataToEncode=""; $DataToPrint=""; $WeightValue=""; $C128_CheckDigit=""; $WeightedTotal=""; $i=""
]; vPrintableString ) //end let
) //end case
) //end let
) //end case
// ===================================
/*
This function is published on FileMaker Custom Functions
to check for updates and provide feedback and bug reports
please visit http://www.fmfunctions.com/fid/182
Prototype: cfCode128( pString; pCodeSet )
Function Author: Tammo Fornalik / Felix Hausberner (http://www.fmfunctions.com/mid/131)
Last updated: 14 January 2009
Version: 1.2
*/
// ===================================
/*__LITBR__cfCode128 ( pString; pCodeSet )__LITBR____LITBR__---use with FM version >= 10---__LITBR__composes the final barcode Code128 of symbology A,B or C from a given alphanumeric string.__LITBR__includes the checksum of the string (modulo 103) as well as start/stop characters.__LITBR__this CF is meant to be used with barcode font "IDAutomationC128..."__LITBR__http://www.advancemeants.com/code128fonts/download.htm__LITBR____LITBR__automatic switching between variants A,B,C within a single barcode is not yet supported.__LITBR____LITBR__pString: string to be used as a barcode.__LITBR__pCodeSet: "A" or "B" or "C" are expected.__LITBR__local var $i stores the actual count of loops.__LITBR__be careful, $i var should not be used in a script running at the same time.__LITBR__all vars (although locally stored) should be destroyed when the process is done.__LITBR____LITBR__author: tammo fornalik / felix hausberner, dbyte solutions, 01.06.2008__LITBR__changes: 10.01.2009, Code() and Char() are now native functions in FM10, replaced references to CFs which did that job.__LITBR__type: recursive__LITBR__dependencies: none__LITBR__call like: cfCode128( "SBM16672_2008_08_25"; "B" )__LITBR__*/__LITBR____LITBR__//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> String is empty -> no output__LITBR__Case( IsEmpty( pString ); ""__LITBR____LITBR__//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> CodeSet A, B__LITBR__; pCodeSet = "A" or pCodeSet = "B";__LITBR____LITBR__ Let(__LITBR__ [__LITBR__ vInitOnce = Case( IsEmpty( $i );__LITBR__ //the following inits are only processed during initial call__LITBR__ Let(__LITBR__ [__LITBR__ $C128_Start = Char( Case( pCodeSet = "A"; 203; pCodeSet = "B"; 204; 0 ) ); //defined by C128 specs__LITBR__ $C128_Stop = Char( 206 ); //defined by C128 specs__LITBR__ $DataToEncode = Trim( pString );__LITBR__ $WeightedTotal = Code( $C128_Start ) -100; //font specific__LITBR__ $C128_CheckDigit = "w"; //font specific, on internal error__LITBR__ $i = 0__LITBR__ ]; "" ); //end let__LITBR__ "" ); //end case__LITBR____LITBR__ $i = $i +1;__LITBR__ //get the value of each character. calculate the WeightedTotal for modulo 103 checksum.__LITBR__ vCurrentChar = Code( Middle( $DataToEncode; $i; 1 ) );__LITBR__ vCurrentVal = Case( vCurrentChar < 135; vCurrentChar -32; vCurrentChar > 134; vCurrentChar -100 );__LITBR__ vCurrentVal = vCurrentVal * $i;__LITBR__ $WeightedTotal = $WeightedTotal + vCurrentVal__LITBR__ ];__LITBR____LITBR__ Case(__LITBR__ $i < Length( $DataToEncode ); cfCode128( $DataToEncode; pCodeSet ); //recursion__LITBR__ Let(__LITBR__ [__LITBR__ //divide the WeightedTotal by 103 and get the remainder, this is the CheckDigitValue__LITBR__ vChkDigitVal = Mod( $WeightedTotal; 103 );__LITBR__ //map CheckDigit to font specific chars__LITBR__ $C128_CheckDigit = Char( Case( vChkDigitVal = 0; 194; vChkDigitVal < 95 and vChkDigitVal > 0; vChkDigitVal +32; vChkDigitVal > 94; vChkDigitVal +100 ) );__LITBR__ $DataToEncode = Substitute ( $DataToEncode; Char( 32 ); Char( 194 ) ); //replace the spaces with the 194 character, font specific__LITBR__ vPrintableString = $C128_Start & $DataToEncode & $C128_CheckDigit & $C128_Stop;__LITBR__ $C128_Start=""; $C128_Stop=""; $DataToEncode=""; $C128_CheckDigit=""; $WeightedTotal=""; $i="" //kill vars__LITBR__ ]; vPrintableString ) //end let__LITBR__ ) //end case__LITBR____LITBR__ ) //end let__LITBR____LITBR____LITBR__//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> CodeSet C__LITBR__; pCodeSet = "C";__LITBR____LITBR__ Let(__LITBR__ [__LITBR__ vInitOnce = Case( IsEmpty( $i );__LITBR__ Let(__LITBR__ [__LITBR__ $C128_Start = Char( 205 );__LITBR__ $C128_Stop = Char( 206 );__LITBR__ $DataToEncode = Filter( pString ; "0123456789" );__LITBR__ vCountOfDigitsIsOdd = Mod( Length( $DataToEncode ); 2 ) = 1;__LITBR__ $DataToEncode = Case( vCountOfDigitsIsOdd; "0"; "" ) & $DataToEncode;__LITBR__ $DataToPrint = "";__LITBR__ $WeightValue = 0;__LITBR__ $WeightedTotal = Code( $C128_Start ) -100;__LITBR__ $C128_CheckDigit = "w";__LITBR__ $i = -1 //...so the first used value will be 1__LITBR__ ]; "" ); //end let__LITBR__ "" ); //end case__LITBR____LITBR__ $i = $i +2;__LITBR__ $WeightValue = $WeightValue +1;__LITBR__ vCurrentChar = Middle( $DataToEncode; $i; 2 );__LITBR__ $DataToPrint = $DataToPrint & Case( vCurrentChar < 95 and vCurrentChar > 0; Char( vCurrentChar +32 ); vCurrentChar > 94; Char( vCurrentChar +100 ); vCurrentChar = 0; Char( 194 ) );__LITBR__ $WeightedTotal = $WeightedTotal + (vCurrentChar * $WeightValue)__LITBR__ ];__LITBR____LITBR__ Case(__LITBR__ $i < Length( $DataToEncode ); cfCode128( $DataToEncode; pCodeSet ); //recursion__LITBR__ Let(__LITBR__ [__LITBR__ vChkDigitVal = Mod( $WeightedTotal; 103 );__LITBR__ $C128_CheckDigit = Char( Case( vChkDigitVal < 95 and vChkDigitVal > 0; vChkDigitVal +32; vChkDigitVal > 94; vChkDigitVal +100; vChkDigitVal = 0; 194 ) );__LITBR__ vPrintableString = $C128_Start & $DataToPrint & $C128_CheckDigit & $C128_Stop;__LITBR__ $C128_Start=""; $C128_Stop=""; $DataToEncode=""; $DataToPrint=""; $WeightValue=""; $C128_CheckDigit=""; $WeightedTotal=""; $i=""__LITBR__ ]; vPrintableString ) //end let__LITBR__ ) //end case__LITBR____LITBR__ ) //end let__LITBR____LITBR__) //end case__LITBR____LITBR__// ===================================__LITBR__/*__LITBR____LITBR__ This function is published on FileMaker Custom Functions__LITBR__ to check for updates and provide feedback and bug reports__LITBR__ please visit http://www.fmfunctions.com/fid/182__LITBR____LITBR__ Prototype: cfCode128( pString; pCodeSet )__LITBR__ Function Author: Tammo Fornalik / Felix Hausberner (http://www.fmfunctions.com/mid/131)__LITBR__ Last updated: 14 January 2009__LITBR__ Version: 1.2__LITBR____LITBR__*/__LITBR__// ===================================