3838currentglobal
3939true setglobal
4040/setpacking where {pop currentpacking true setpacking} if
41- 10 dict
42- dup /loadctx dup /uk.co.terryburton.bwipp findresource put
43- dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
41+ 50 dict
4442dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
4543dup /processoptions dup /uk.co.terryburton.bwipp findresource put
4644dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
4745dup /codablockf dup /uk.co.terryburton.bwipp findresource put
4846begin
47+
48+ /hibccodablockf.barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) readonly def
49+
50+ /hibccodablockf.latevars dup 1 dict def load /init {
51+
52+ currentglobal
53+ true setglobal
54+
55+ //hibccodablockf.latevars begin
56+
57+ /charvals 43 dict def
58+ 0 1 42 {
59+ charvals exch dup //hibccodablockf.barchars exch 1 getinterval exch put
60+ } for
61+ /charvals charvals readonly def
62+
63+ /init { //hibccodablockf.latevars {def} forall } def
64+
65+ end
66+
67+ //hibccodablockf.latevars /init get exec
68+
69+ setglobal
70+
71+ } bind put
72+
4973/hibccodablockf {
5074
51- 20 dict begin % Confine variables to local scope
75+ 20 dict begin
5276
5377 /ctx null def
5478 /dontdraw false def
@@ -57,20 +81,15 @@ begin
5781 //processoptions exec /options exch def
5882 /barcode exch def
5983
84+ //hibccodablockf.latevars /init get exec
85+
6086 barcode () eq {
6187 /bwipp.hibccodablockfEmptyData (The data must not be empty) //raiseerror exec
6288 } if
6389
64- /hibccodablockf //loadctx exec
65-
66- % Create a string of the available characters
67- {
68- /barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
69- /charvals 43 dict def
70- 0 1 42 {charvals exch dup barchars exch 1 getinterval exch put} for
71- } ctxdef
72-
90+ %
7391 % Validate the input
92+ %
7493 0 1 barcode length 1 sub {
7594 barcode exch 1 getinterval charvals exch known not {
7695 /bwipp.hibccodablockfBadCharacter (HIBC Codablock F must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec
@@ -86,17 +105,19 @@ begin
86105 } for
87106 /checksum checksum 43 mod def
88107 validatecheck {
89- barcode barlen get barchars checksum get ne {
108+ barcode barlen get //hibccodablockf. barchars checksum get ne {
90109 /bwipp.hibccodablockfBadCheckDigit (Incorrect HIBC Codablock F check digit provided) //raiseerror exec
91110 } if
92111 /barcode barcode 0 barlen getinterval def
93112 } if
94113
95114 /barcode barlen 2 add string dup 1 barcode putinterval def
96115 barcode 0 43 put
97- barcode barlen 1 add barchars checksum get put
116+ barcode barlen 1 add //hibccodablockf. barchars checksum get put
98117
118+ %
99119 % Get the result of encoding with codablockf
120+ %
100121 options (dontdraw) true put
101122 options (validatecheck) false put
102123 /args barcode options //codablockf exec def
@@ -106,8 +127,6 @@ begin
106127
107128 dontdraw not //renmatrix if
108129
109- //unloadctx exec
110-
111130 end
112131
113132}
0 commit comments