Monday, January 11, 2016

Create Code128 Bar Code in NAV 2009

Hi all,
Today I posted how you can Create Code128 Bar Code.

//------Define parameter-------->>
Var Name DataType Subtype Length
No CodeString Text 250
//<<------------END-------------------

//------Define Return Value-------->>
Name 128BCodeString
Return Type Text
Length 250
//<<------------END-------------------

//------Define Variables-------->>
Name DataType Subtype Length
Offset Integer
HighAscii Integer
Total Integer
iCounter Integer
Holder Integer
Check Integer
ASCIIValue Integer
CheckDigit Integer
Character Char
//<<------------END-------------------

//------Define Functions-------------->>
CreateCode128BFont(CodeString : Text[250]) "128BCodeString" : Text[250]
//--------------START----------------->>
CLEAR(Offset);
CLEAR(HighAscii);
CLEAR(Total);
CLEAR(iCounter);
CLEAR(Holder);
CLEAR(Check);
CLEAR(Character);
CLEAR(ASCIIValue);
CLEAR(CheckDigit);

Offset := 32;
HighAscii := 66;
"128BCodeString"[1] := Offset + HighAscii + 104;
Total := 104;

FOR iCounter := 1 TO STRLEN(CodeString) DO BEGIN
  Character := CodeString[iCounter];
  ASCIIValue := Character;
  CheckDigit := ((ASCIIValue - Offset) * (iCounter));
  Total += CheckDigit;
  "128BCodeString"[iCounter + 1] := ASCIIValue;
END;
Check := Total MOD 103;
Holder := 0;

IF (Check + Offset >= 127) THEN
  Holder := Check + Offset + HighAscii
ELSE
  Holder := Check + Offset;


"128BCodeString"[STRLEN("128BCodeString")+1] := Holder;
Holder := 106 + Offset + HighAscii;
"128BCodeString"[STRLEN("128BCodeString")+1] := Holder;

CLEAR(iCounter);
FOR iCounter := 1 TO STRLEN("128BCodeString") DO
  IF("128BCodeString"[iCounter] = 32) THEN
    "128BCodeString"[iCounter] := 177;

EXIT("128BCodeString");
//<<----------------END-------------------


Thanks & Best Wishes
Binesh Singh Rajput
(MCP, MS, MCTS)

No comments:

Post a Comment

Popular Posts