Script Library: 1213 scripts
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Discussion posts for script code39.r

1
notchent
12-Mar-2010 3:38
REBOL [title: "code39 barcode generator"]

barcode-string: "123 hat"
barcode-file: %code39.png

barcode-width: 1      ; default 1
barcode-height: 40    ; default 40
xshift: 20            ; default 20
yshift: 20            ; default 20

code39: [
    "1" "110100101011"
    "2" "101100101011"
    "3" "110110010101"
    "4" "101001101011"
    "5" "110100110101"
    "6" "101100110101"
    "7" "101001011011"
    "8" "110100101101"
    "9" "101100101101"
    "0" "101001101101"
    "A" "110101001011"
    "B" "101101001011"
    "C" "110110100101"
    "D" "101011001011"
    "E" "110101100101"
    "F" "101101100101"
    "G" "101010011011"
    "H" "110101001101"
    "I" "101101001101"
    "J" "101011001101"
    "K" "110101010011"
    "L" "101101010011"
    "M" "110110101001"
    "N" "101011010011"
    "O" "110101101001"
    "P" "101101101001"
    "Q" "101010110011"
    "R" "110101011001"
    "S" "101101011001"
    "T" "101011011001"
    "U" "110010101011"
    "V" "100110101011"
    "W" "110011010101"
    "X" "100101101011"
    "Y" "110010110101"
    "Z" "100110110101"
    "-" "100101011011"
    "." "110010101101"
    " " "100110101101"
    "*" "100101101101"
    "$" "100100100101"
    "/" "100100101001"
    "+" "100101001001"
    "%" "101001001001"
]
convfrom: rejoin ["*" barcode-string "*"]
out: copy [backdrop white]
x: 0
foreach char convfrom [
    pattern: select code39 form char
    foreach bit pattern [
        x: x + 1
        if bit = #"1" [
            append out compose [

                at (to-pair reduce [((x * barcode-width) + xshift) yshift])

                box (to-pair reduce [barcode-width barcode-height]) black
            ]
        ]
    ]
    x: x + 1
]

save/png barcode-file to-image layout out  ; layout/tight out
browse barcode-file