4D Source Code for IDAutomation.com Barcode Fonts Copyright © IDAutomation.com, Inc. 2002, All rights reserved. NOTE: The following code is only an example that was provided by Objective Systems, LLC. Objective Systems is available is a consultant for implementing our barcode fonts into 4D for a reasonable fee. They can be contacted at www.objectivesys.com. IDAutomation.com, Inc. does not guarantee, support or troubleshoot this source code. `PM: OS_Compute128BarCheckSum(InputString)->BarCodeString `4D Source Code for IDAutomation.com Barcode Fonts `This method takes an ASCII text string and converts it to a string so `that when combined with the Code 128 Barcode Font from IDAutomation.com `will create a correct barcode. http://www.idautomation.com/ ` `Copyright © IDAutomation.com, Inc. 2002, All rights reserved. `Change History ?ObjSys031102:=True `created ?ObjSys052508:=True `modifed to use the 128B font from ID Automation dated 3/24/02 `This font is compatible with both Mac & Windows `Declarations & Initialization C_TEXT($1;$InputString;$0;$ReturnString) C_LONGINT($LoopCounter;$StringLength;$StringSum;$CurrentCharValue;$CurrentAdjusted;$CheckDigitValue) C_TEXT($StartCharacter;$StopCharacter;$CheckSumCharacter) $InputString:=$1 `Reassign the Input parameters $ReturnString:="" `Start of Method $StringLength:=Length($InputString) `Get the length of the input string; used in the For Loop $StartCharacter:=Char(204) `Establishes the "B" code set defined by Code128; this is defined by the spec $StopCharacter:=Char(206) `Establishes the Stop defined by Code128; this is defined by the spec `The CheckDigit is defined by the Code 128 spec as `The Modulus 103 of the sum of the StartCode plus the sum of the Product of ` the VALUE of each character of the string times its position in the string `The VALUE is the ASCII value less 32 (which is the Space character). Only ` values above the Space character are included in the Code128 character set `The string consists of the StartCode, the String, the ASCII of the CheckDigit+32 ` and the StopCode `----- Compute the CheckDigit ------- $StringSum:=Num($StartCharacter) `Intialize the StringSum to the value of the StartCode For ($LoopCounter;1;$StringLength) `loop through the string, starting at the most significant digit $CurrentCharValue:=Ascii($InputString=$LoopCounter=) $CurrentAdjustedValue:=0 `Adjust the Value based on the Charcter range as defined by the font manufacturer Case of : ($CurrentCharValue<135) $CurrentAdjustedValue:=$CurrentCharValue-32 : ($CurrentCharValue>134) $CurrentAdjustedValue:=$CurrentCharValue-100 Else $CurrentAdjustedValue:=$CurrentCharValue End case $StringSum:=$StringSum+($LoopCounter*$CurrentAdjustedValue) `Get the Product of the value (less 32) * the position End for $CheckDigitValue:=Mod($StringSum;103) `Get the Modulus103, `Now that we have the CheckDigitValue, find the corresponding ASCII character ` from the table for this font Case of : ($CheckDigitValue=0) $CheckDigitCharacter:=Char(194) : (($CheckDigitValue<95) & ($CheckDigitValue>0)) $CheckDigitCharacter:=Char($CheckDigitValue+32) : ($CheckDigitValue>94) $CheckDigitCharacter:=Char($CheckDigitValue+100) Else $CheckDigitCharacter:=Char($CheckDigitValue) End case `Now check the Input string for spaces or "00" and print 194 instead `Put the revised data in $DataToPrint $DataToPrint:="" For ($LoopCounter;1;$StringLength) $CurrentCharacter:=$InputString=$LoopCounter= If ($CurrentCharacter=" ") $CurrentCharacter:=Char(194) End if $DataToPrint:=$DataToPrint+$CurrentCharacter End for $ReturnString:=$StartCharacter+$DataToPrint+$CheckDigitCharacter+$StopCharacter $0:=$ReturnString `