home *** CD-ROM | disk | FTP | other *** search
- /* This program covers the related formats UPC, EAN and ISBN and forms part of the ProDraw barcoding program. It is called by BarCodes.pdrx.
- Written by Don Cox. Copyright. Not Public Domain. */
-
- /* $VER: BarCodesEAN.rexx Jan 95 */
- /*call open("STDERR","ram:traceEAN","W")
- trace r*/
-
- parse arg chosen, box, colour1, colour2, numberprompt, oldunits
- cr = "0a"x
-
- EANtype = 13
- if pos("ISBN",chosen)~=0 then EANtype = 10
- if pos("8",chosen)~=0 then EANtype = 8
- if pos("UPC-A",chosen)~=0 then EANtype = 12
- if pos("UPC-E",chosen)~=0 then EANtype = 7
-
- identity = 1 /* count objects */
- curves. = ""
- parse var box cornerX cornerY cornerX2 cornerY2
-
-
- call numberdata.rexx() /* External program sets up data for numbers */
-
- /* get values from last run from clips or supply defaults */
-
- suppprompt = getclip(pdussupp)
- magfactor = getclip(pdusmagfactor)
- if magfactor = "" then magfactor = 1
- artscale = getclip(pdusartscale)
- if artscale = "" then artscale = 1
- cornermarks = getclip(pduscornermarks)
- if cornermarks = "" then cornermarks = "Y"
- trunc = getclip(pdustrunc)
- if trunc = "" then trunc = 0
- bookcode = getclip(pdusbookcode)
- if bookcode = "" then bookcode = 978
-
- numbertext = "Code Numbers:"
- if pos("ISBN",chosen)~=0 then numbertext = "ISBN number:"
-
- prompt = numbertext||numberprompt ||cr|| "Ink Spread(mm):0.000" ||cr|| "Mag. factor:"magfactor ||cr|| "Artwork scale:"artscale ||cr|| "Select colours?(Y/N):N" ||cr|| "Corner Marks?(Y/N):"cornermarks ||cr|| "Truncation (mm):"trunc
-
- if pos("plus",chosen)~=0 then prompt = prompt||cr|| "Supplement Code:"suppprompt
- if pos("ISBN",chosen)~=0 then prompt = prompt||cr|| "Book code (977-9):"bookcode
-
- form = pdm_GetForm("Enter numbers",17,prompt)
- parse var form numbers "0a"x inkspread "0a"x magfactor "0a"x artscale "0a"x colorset "0a"x cornermarks "0a"x trunc "0a"x options
-
- if pos("plus",chosen)=0 then bookcode = options
- if pos("ISBN",chosen)=0 then supplement = options
- else if pos("ISBNplus",chosen)~=0 then parse var options supplement "0a"x bookcode
-
- if supplement = "" then chosen = compress(chosen,"plus25")
- inkspread = inkspread/10 /* convert to cm */
-
- if numbers = "" then exit_msg("User aborted genie")
- numbers = space(numbers,0) /* strip out all spaces */
- numlength = length(numbers)
- call setclip(pdusnumbers, numbers)
-
- oklength = EANtype-1
-
- if numlength<oklength then exit_msg("Should be "oklength" digits")
- numbers = left(numbers,oklength)
- numlength = oklength
-
- numbers = clearos(numbers) /* replace any letter Os with zeros */
- call setclip(pdusnumbers, numbers)
- ver = verify(numbers,"0123456789")
- if ver~= 0 then exit_msg("Letter "substr(numbers,ver,1)" among numbers")
- numbers = checksum(numbers) /* calculate checksum */
-
- if upper(numberfont)~="N" then numberfont = pdm_GetFontList
-
- if upper(colorset)~="N" then do
- colourpair = setcolors()
- parse var colourpair colour1 "0a"x colour2
- end
-
- if EANtype = 10 then do /* ISBN codes */
- bookcode = space(bookcode,0) /* strip out all spaces */
- bookcode = clearos(bookcode)
- if length(bookcode)<3 then exit_msg("Book code needs 3 figures")
- bookcode = left(bookcode,3)
- call setclip(pdusbookcode,bookcode)
- ver =verify(bookcode,"0123456789")
- if ver~=0 then exit_msg("Letter "substr(bookcode,ver,1)" in bookcode")
-
- num1 = substr(numbers,1,1)
- num2 = substr(numbers,2,4)
- num3 = substr(numbers,6,4)
- num4 = substr(numbers,10,1)
- ISBNstring = "ISBN "num1"-"num2"-"num3"-"num4
- if bookcode = 977 then ISBNstring = "ISSN "num1"-"num2"-"num3"-"num4
- numbers = bookcode||num1||num2||num3
- numbers = checksum(numbers)
- end
-
- numbers2 = numbers /* string for drawing numerals */
- numlength = length(numbers)
-
- if ~datatype(magfactor,n) then magfactor = 1
- if magfactor<0.82 then magfactor = 0.82
- if magfactor>2 then magfactor = 2
-
- if ~datatype(artscale,n) then artscale = 1
- if upper(cornermarks)~="Y" then cornermarks = "N"
-
- if ~datatype(trunc,n) then trunc = 0
- if magfactor<1 then trunc = 0
- maxtrunc = ((8*(magfactor-1))+3.8)*artscale
- if trunc> maxtrunc then trunc = maxtrunc
-
- call setclip(pdusmagfactor, magfactor)
- call setclip(pdusartscale, artscale)
- call setclip(pduscornermarks, cornermarks)
- call setclip(pdustrunc, trunc)
-
- if pos("plus",chosen)~=0 then do
- supplement = space(supplement,0) /* strip out all spaces */
- supplement = clearos(supplement)
- suppoklength = right(chosen,1)
- supplement = left(supplement,suppoklength)
- call setclip(pdussupp,supplement)
- supplength = length(supplement)
- if supplength~=suppoklength then exit_msg("Wrong supplement: "supplement)
- ver =verify(supplement,"0123456789")
- if ver~=0 then exit_msg("Letter "substr(supplement,ver,1)" in supplement")
- end
-
- scaler = magfactor*artscale*0.1 /* 0.1 to convert mm to cm */
- unitwidth = 0.330*scaler
-
-
- /* Set up dimensions for various formats. If truncated, top positions are left unchanged and bottoms brought up. */
- select
- when EANtype = 8 then do /* EAN 8 code */
- guardbottom = cornerY+((0.33+19.8-trunc)*scaler)
- codebottom = cornerY+ ((0.33+18.23-trunc)*scaler)
- bartop = cornerY+(0.33*scaler)
- supptop = cornerY+(5*scaler)
- barleft = cornerX + (2.31*scaler)
- numberleft = barleft+(5*unitwidth)
- numbertop = cornerY+ ((0.33+18.56-trunc)*scaler)
- boxwidth = 26.73*scaler
- boxheight = (21.64-trunc)*scaler
- end
-
- when EANtype = 7 then do /* UPC E code */
- guardbottom = cornerY+((1.59+24.37)*scaler) /* 1.59 top margin */
- codebottom = cornerY+ ((1.59+22.05)*scaler)
- bartop = cornerY+(1.59*scaler)
- supptop = cornerY+(5*scaler)
- barleft = cornerX + (2.97*scaler)
- numberleft = barleft+(5*unitwidth)
- numbertop = cornerY+ ((1.59+22.34)*scaler)
- boxwidth = 22.11*scaler
- boxheight = (1.59+24.99)*scaler
- end
-
- when EANtype = 10 then do /* ISBN code */
- cornerY2 = cornerY+(4*scaler) /* top strip for ISBN number */
- ISBNtop = cornerY+(0.8*scaler)
- guardbottom = cornerY2+((0.33+24.5-trunc)*scaler)
- codebottom = cornerY2+ ((0.33+22.85-trunc)*scaler)
- bartop = cornerY2+(0.33*scaler)
- supptop = cornerY2+(5*scaler)
- barleft = cornerX + (3.63*scaler)
- ISBNleft = barleft
- numberleft = cornerX + (0.33*scaler)
- numbertop = cornerY2+ ((0.33+23.18-trunc)*scaler)
- boxwidth = 37.29*scaler
- boxheight = (30.26-trunc)*scaler
- end
-
- when EANtype = 13 then do /* EAN 13 code */
- ISBNtop = cornerY+(0.5*scaler)
- guardbottom = cornerY+((0.33+24.5-trunc)*scaler)
- codebottom = cornerY+ ((0.33+22.85-trunc)*scaler)
- bartop = cornerY+(0.33*scaler)
- supptop = cornerY+(5*scaler)
- barleft = cornerX + (3.63*scaler)
- numberleft = cornerX + (0.33*scaler)
- numbertop = cornerY + ((0.33+23.18-trunc)*scaler)
- boxwidth = 37.29*scaler
- boxheight = (26.26-trunc)*scaler
- end
-
- when EANtype = 12 then do /* UPC A code */
- guardbottom = cornerY+((1.59+24.37)*scaler) /* 1.59 top margin */
- codebottom = cornerY+ ((1.59+22.05)*scaler)
- bartop = cornerY+(1.59*scaler)
- supptop = cornerY+(5*scaler)
- barleft = cornerX + (2.97*scaler)
- numberleft = cornerX - (0.1*scaler)
- numbertop = cornerY+ ((1.59+22.34)*scaler)
- smalltop = cornerY+ ((1.59+23.3)*scaler) /* top of small numerals */
- boxwidth = 37.29*scaler
- boxheight = (1.59+24.99)*scaler
- end
-
- otherwise NOP
- end
-
- if pos("plus2",chosen)~=0 then boxwidth = boxwidth+(unitwidth*30)
- if pos("plus5",chosen)~=0 then boxwidth = boxwidth+(unitwidth*60)
-
-
- charwidth = unitwidth*7 /* size of numerals */
-
- call drawrectangle
-
- /* draw corner marks */
- if cornermarks = "Y" then do
- cornerstring = "0 1 0 0 0 0, 1 1 0 0 0 0, 1 0 0 0 0 0"
- marksize = 4 * unitwidth /* arbitrary */
- markleft = cornerX-marksize
- marktop = cornerY-marksize
- call pdm_InitPlot(markleft, marktop, marksize, marksize, 0)
- call pdm_PlotBezier(cornerstring)
- obj = pdm_EndPlot()
- curves.identity = obj
- call pdm_SetLineJoin(obj,0)
- if pos("UPC",chosen)=0 then call pdm_SetLineWeight(obj, 1.00)
- call pdm_SetFillPattern(obj,0, colour2)
- if pos("UPC",chosen)~=0 then call pdm_SetFillPattern(obj,1, colour2)
- identity = identity+1
-
- markleft = boxright+marksize
- marktop = cornerY-marksize
- call pdm_InitPlot(markleft, marktop, marksize, marksize, 270)
- call pdm_PlotBezier(cornerstring)
- curves.identity = pdm_EndPlot()
- identity = identity+1
-
- markleft = boxright+marksize
- marktop = boxbottom+marksize
- call pdm_InitPlot(markleft, marktop, marksize, marksize, 180)
- call pdm_PlotBezier(cornerstring)
- curves.identity = pdm_EndPlot()
- identity = identity+1
-
- markleft = cornerX-marksize
- marktop = boxbottom+marksize
- call pdm_InitPlot(markleft, marktop, marksize, marksize, 90)
- call pdm_PlotBezier(cornerstring)
- curves.identity = pdm_EndPlot()
- /* if pos("UPC",chosen)=0 then call pdm_SetLineWeight(obj, 1.00)
- if pos("UPC",chosen)~=0 then call pdm_SetFillPattern(obj,1, colour2)*/
- identity = identity+1
- end
-
-
- /* The numbers here represent the widths of the bars in the character patterns. The printed width of a unit-width bar should be 0.013 inch. */
- LAstring = "3211 2221 2122 1411 1132 1231 1114 1312 1213 3112"
- LBstring = "1123 1222 2212 1141 2311 1321 4111 2131 3121 2113"
- Rstring = "3211 2221 2122 1411 1132 1231 1114 1312 1213 3112"
- thstring = "AAAAAA AABABB AABBAB AABBBA ABAABB ABBAAB ABBBAA ABABAB ABABBA ABBABA"
-
- /* The left & right blocks of numbers */
- EANtype2 = EANtype
- if EANtype2 = 10 then EANtype2 = 13 /* ISBN same as EAN 13 */
- leftstart = 1
- leftend = EANtype2 %2 /* half the number of digits, ignoring remainder */
- rightstart = leftend+1
- rightend = EANtype2-(EANtype2 //2)
-
- ABpattern="AAAAAA" /* for EAN8 and UPC-A */
- if EANtype2 = 7 then ABpattern = "BBBBBBB"
-
- if EANtype2 = 13 then do /* for EAN13 & ISBN */
- firstnumber = left(numbers,1)
- ABpattern = word(thstring,firstnumber+1)
- numbers = substr(numbers,2)
- end
-
- call pdm_ShowStatus(" Drawing Bars..")
-
- currentfill = colour1
-
- /* Guard bars */
- barbottom = guardbottom
- do j = 1 to 3
- barwidth = 1
- barright = barleft + unitwidth
- if currentfill = colour1 then call drawbar
- else currentfill = colour1
- barleft = barright
- end
-
- /* First block of number bars */
-
- do i= leftstart to leftend
- barbottom = codebottom
- if EANtype2 = 12 then if i=leftstart then barbottom = guardbottom
- thisnumber = substr(numbers, i,1)
- if thisnumber = "" then break
- AorB = substr(ABpattern,i,1)
- call doleftpattern
- end
-
- /* Centre guard bars */
- if EANtype2~=7 then do
- barbottom = guardbottom
- do j = 1 to 5
- barwidth = 1
- barright = barleft + unitwidth
- if currentfill = colour1 then call drawbar
- else currentfill = colour1
- barleft = barright
- end
- end
-
- /* second block of number bars */
- barbottom = codebottom
- do i=rightstart to rightend
- if EANtype2 = 12 then if i=rightend then barbottom = guardbottom
- thisnumber = substr(numbers, i,1)
- if thisnumber = "" then break
- barpattern = word(Rstring, thisnumber+1)
- do j = 1 to 4
- barwidth = substr(barpattern,j,1)
- barright = barleft + (barwidth * unitwidth)
- if currentfill = colour1 then call drawbar
- else currentfill = colour1
- barleft = barright
- end
- end
-
- /* Guard bars */
- barbottom = guardbottom
- n = 3
- if EANtype2 = 7 then n=6
- do j = 1 to n
- barwidth = 1
- barright = barleft + unitwidth
- if currentfill = colour1 then call drawbar
- else currentfill = colour1
- barleft = barright
- end
-
-
- /* Do supplementary bars */
- if pos("plus",chosen) ~=0 then do
- barbottom = guardbottom
- mainbartop = bartop
- bartop = supptop
- barleft = barleft+(10*unitwidth) /* Guard bars */
- suppleft = barleft+(unitwidth*4) /* left position for supplement numerals */
- barwidth = 1
- barright = barleft + unitwidth
- call drawbar
- barleft = barright+unitwidth
-
- barright = barleft + (2*unitwidth)
- call drawbar
- barleft = barright
-
- end
-
-
- /* Two digit supplement */
- if pos("2",chosen)~=0 then do
- supplement = left(supplement,2)
- if ~datatype(supplement,"N") then exit_msg(supplement||" not a number")
- thisnumber = left(supplement,1)
- digpar = supplement//4 /* parity code */
- AorB = "B"
- if digpar = 0 | digpar = 1 then AorB = "A"
- call doleftpattern
-
- /* delineator is 01 */
- barleft = barright+unitwidth
- barright = barleft + unitwidth
- call drawbar
- barleft = barright
-
- thisnumber = right(supplement,1)
- AorB = "B"
- if digpar = 0 | digpar = 2 then AorB = "A"
- call doleftpattern
- end
-
-
- /* Five digit supplement */
- if pos("5",chosen)~=0 then do
- supplement = left(supplement,5)
- if ~datatype(supplement,"N") then exit_msg(supplement||" not a number")
- ch=checksum5(supplement)
- ch = ch+1
- fivestring = "BBAAA BABAA BAABA BAAAB ABBAA AABBA AAABB ABABA ABAAB AABAB"
- ABpattern = word(fivestring,ch)
-
- thisnumber = substr(supplement,1,1)
- if thisnumber = "" then break
- if thisnumber = "O"| thisnumber = "o" then thisnumber = 0
- AorB = substr(ABpattern,1,1)
- call doleftpattern
-
- /* delineator is 1 */
- barleft = barright+unitwidth
- barright = barleft + unitwidth
- call drawbar
- barleft = barright
-
- thisnumber = substr(supplement,2,1)
- if thisnumber = "" then break
- if thisnumber = "O"| thisnumber = "o" then thisnumber = 0
- AorB = substr(ABpattern,2,1)
- call doleftpattern
-
- /* delineator is 01 */
- barleft = barright+unitwidth
- barright = barleft + unitwidth
- currentfill = colour2
- obj = pdm_DrawRectangle(barleft, supptop, barright, guardbottom)
- call pdm_SetLineWeight(obj, 0.00)
- call pdm_SetFillPattern(obj,1, currentfill)
- curves.identity = obj
- identity = identity+1
- barleft = barright
-
- thisnumber = substr(supplement,3,1)
- if thisnumber = "" then break
- if thisnumber = "O"| thisnumber = "o" then thisnumber = 0
- AorB = substr(ABpattern,3,1)
- call doleftpattern
-
- /* delineator is 1 */
- barleft = barright+unitwidth
- barright = barleft + unitwidth
- call drawbar
- barleft = barright
-
- thisnumber = substr(supplement,4,1)
- if thisnumber = "" then break
- if thisnumber = "O"| thisnumber = "o" then thisnumber = 0
- AorB = substr(ABpattern,4,1)
- call doleftpattern
-
- /* delineator is 01 */
- barleft = barright+unitwidth
- barright = barleft + unitwidth
- call drawbar
- barleft = barright
-
- thisnumber = substr(supplement,5,1)
- if thisnumber = "" then break
- if thisnumber = "O"| thisnumber = "o" then thisnumber = 0
- AorB = substr(ABpattern,5,1)
- call doleftpattern
-
- end
-
-
-
- call pdm_ShowStatus(" Drawing Numerals..")
-
- scaleX = charwidth/4.5 /* this arbitrary number depends on the size of characters in the data strings */
- scaleY = scaleX /* keep proportions - ignore box height */
-
- do i = 1 to numlength
- thisnumber = substr(numbers2, i,1)
-
- if EANtype = 12 then do
- if i=1 then do
- scaleX = scaleX*0.6 /* small first character for UPC-A */
- scaleY=scaleX
- normaltop = numbertop
- numbertop=smalltop
- end
- if i=12 then do
- scaleX = scaleX*0.6
- scaleY=scaleX
- numbertop = smalltop
- end
- end
-
- call drawnumber
-
- numberleft = numberleft + charwidth /* move to next position*/
- if EANtype = 12 then do
- if i=1 then do
- numberleft = numberleft + (charwidth*2) /* extra for first */
- scaleX = charwidth/4.5 /* back to standard size */
- scaleY = scaleX
- numbertop=normaltop
- end
- if i=11 then numberleft = numberleft + (charwidth*2) /* extra for last */
- if i= 6 then numberleft = numberleft +(4*unitwidth) /* extra to skip centre guard bars */
- end
-
- if (EANtype = 13 | EANtype = 10) then do
- if i=1 then numberleft = numberleft + charwidth /* extra for first */
- if i= rightstart then numberleft = numberleft +(4*unitwidth) /* extra to skip centre guard bars */
- end
-
- if EANtype = 8 then if i = leftend then numberleft = numberleft+(4*unitwidth)
-
- if EANtype = 7 then if i = rightend then numberleft = numberleft + (6*unitwidth)
- end
-
- if pos("plus",chosen)=0 then do
- numberleft = numberleft+ (4*unitwidth)
- thisnumber = ">"
- call drawnumber
- end
-
- if EANtype = 8 then do
- numberleft = cornerX
- thisnumber = "<"
- call drawnumber
- end
-
-
- if pos("plus",chosen)~=0 then do /* numerals for supplement */
- scaleX = charwidth/4.5 /* this arbitrary number depends on the size of characters in the data strings */
- scaleY = scaleX /* keep proportions - ignore box height */
- numberleft = suppleft
- numbertop = mainbartop
- numlength = right(chosen,1) /* 2 or 5 */
- if numlength = 2 then do
- numlength = 3
- supplement = supplement||">"
- end
- do i = 1 to numlength
- thisnumber = substr(supplement, i,1)
- call drawnumber
- numberleft = numberleft + charwidth +(unitwidth*2)/* move to next position*/
- end
- end
-
-
- if pos("ISBN",chosen)~=0 then do /* ISBN code at top */
- scaleX = scaleX*0.8
- scaleY = scaleX
- numberleft = ISBNleft
- numbertop = ISBNtop
- numlength = 18
- do i = 1 to numlength
- thisnumber = substr(ISBNstring, i,1)
- if thisnumber~=" " then call drawnumber
- numberleft = numberleft + (charwidth*0.75) /* move to next position*/
- end
- end
-
- identity = identity-1
- call pdm_SelectObj(curves.1,curves.identity)
- call pdm_GroupObj()
-
-
- return 1 /* end of EAN section */
-
- /* +++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++ */
-
- doleftpattern:
- if AorB = "A" then barpattern = word(LAstring, thisnumber+1)
- else barpattern = word(LBstring, thisnumber+1)
- do j = 1 to 4
- barwidth = substr(barpattern,j,1)
- barright = barleft + (barwidth * unitwidth)
- if currentfill = colour1 then call drawbar
- else currentfill = colour1
- barleft = barright
- end
- return
-
- /* ++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++ */
-
- drawbar:
-
- currentfill = colour2
- barleft2 = barleft+inkspread
- barright2 = barright-inkspread
- obj = pdm_DrawRectangle(barleft2, bartop, barright2, barbottom)
- call pdm_SetLineWeight(obj, 0.00)
- call pdm_SetFillPattern(obj,1, currentfill)
- curves.identity = obj
- identity = identity+1
-
- return
-
- /* ++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++ */
-
- drawnumber:
-
- thisclip = "pdusnumdata"||thisnumber
- thisdata = getclip(thisclip)
- parse var thisdata boxsizeX "0a"x boxsizeY "0a"x numstring1 "0a"x numstring2 "0a"x numstring3
-
- call pdm_initplot(numberleft, numbertop, scaleX, scaleY, 0)
- call pdm_PlotBezier(numstring1)
- obj = pdm_ClosePlot()
- curves.identity = obj
- call pdm_SetLineWeight(obj, 0.00)
- call pdm_SetFillPattern(obj,1, colour2)
- identity = identity+1
-
- if numstring2 ~="" then do /* holes in numerals - use solid fills, not compound objects */
- call pdm_initplot(numberleft, numbertop, scaleX, scaleY, 0)
- call pdm_PlotBezier(numstring2)
- obj = pdm_ClosePlot()
- curves.identity = obj
- call pdm_SetLineWeight(obj, 0.00)
- call pdm_SetFillPattern(obj,1, colour1)
- identity = identity+1
- end
- if numstring3 ~="" then do /* some have 2 holes */
- call pdm_initplot(numberleft, numbertop, scaleX, scaleY, 0)
- call pdm_PlotBezier(numstring3)
- obj = pdm_ClosePlot()
- curves.identity = obj
- call pdm_SetLineWeight(obj, 0.00)
- call pdm_SetFillPattern(obj,1, colour1)
- identity = identity+1
- end
- return
-
- /* +++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++ */
-
- /* draw background rectangle */
- drawrectangle:
- currentfill = colour1
- boxright = cornerX + boxwidth
- boxbottom = cornerY + boxheight
- obj = pdm_DrawRectangle(cornerX, cornerY, boxright, boxbottom)
- call pdm_SetLineWeight(obj, 0.00)
- call pdm_SetFillPattern(obj,1, currentfill)
- curves.identity = obj
- identity = identity+1
- return
-
- /* +++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++ */
-
- setcolors:
-
- colorlist = pdm_GetColorList()
- colorlist2 = space(colorlist,0)/* remove spaces from names */
- colorlist2 = translate(colorlist2,,"0a"x)/* replace crs by spaces */
- listlength = words(colorlist2)
- if listlength>24 then listlength = 24
- colour1 = pdm_SelectFromList("Select Background Color..", 20, listlength, 0, colorlist)
- if colour1 = '' then colour1 = "WHITE"
- colour2 = pdm_SelectFromList("Select Bar Color..", 20, listlength, 0, colorlist)
- if colour2 = '' then colour2 = "BLACK"
-
- colour1 = strip(colour1) /* remove any spaces */
- colour2 = strip(colour2)
- call setclip(pduscolour1,colour1)
- call setclip(pduscolour2,colour2)
-
- if words(colour1)+words(colour2)= 2 then do /* GetColourData only works on 1-word names */
- colour1data = pdm_GetColorData(colour1)
- colour2data = pdm_GetColorData(colour2)
- parse var colour1data red1 others
- parse var colour2data red2 others
- if abs(red1-red2)<5 then exit_msg("Not enough red contrast")
- end
- colourpair = colour1||"0a"x||colour2
-
- return colourpair
-
- /* ++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++ */
-
- checksum: procedure
- parse arg numstring
-
- pos = length(numstring)
- total = 0
- do until pos<1
- total = total+substr(numstring,pos,1)
- pos=pos-2
- end
- total = total*3
- pos= length(numstring)-1
- total2 = 0
- do until pos<1
- total2 = total2+substr(numstring,pos,1)
- pos=pos-2
- end
- total=total+total2
- ch=10-(total//10)
- if ch=10 then ch = 0
-
- numstring = numstring||ch
- return numstring
-
- /* +++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++ */
-
- checksum5: procedure
- parse arg numstring
-
- pos = length(numstring)
- total = 0
- do until pos<1
- total = total+substr(numstring,pos,1)
- pos=pos-2
- end
- total = total*3
- pos= length(numstring)-1
- total2 = 0
- do until pos<1
- total2 = total2+substr(numstring,pos,1)
- pos=pos-2
- end
- total2 = total2*9
- total=total+total2
- ch=right(total,1)
-
- return ch
-
- /* +++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++ */
-
- clearos: procedure
-
- parse arg numbers
- position = 0 /* now replace O's with zeros */
- do forever
- position = pos("O", numbers,position+1)
- if position = 0 then break
- numbers = delstr(numbers,position,1)
- numbers = insert("0",numbers,position-1)
- end
- position = 0 /* now replace o's with zeros */
- do forever
- position = pos("o", numbers,position+1)
- if position = 0 then break
- numbers = delstr(numbers,position,1)
- numbers = insert("0",numbers,position-1)
- end
- position = 0 /* now remove hyphens */
- do forever
- position = pos("-", numbers,position+1)
- if position = 0 then break
- numbers = delstr(numbers,position,1)
- end
-
- return numbers
-
- /* +++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++ */
-
-
- exit_msg: procedure expose oldunits
- do
- parse arg message
-
- if message ~= '' then call pdm_Inform(1,message,)
- call pdm_ClearStatus()
- call pdm_SetUnits(oldunits)
- call pdm_UpdateScreen(0)
- call pdm_AutoUpdate(1)
- exit
- end
-
-