hp_barcd.p 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. Define variable input-string as character no-undo initial "7616500636248".
  2. Define variable bar-code-string as character no-undo.
  3. /* Run bar-code-39 (input input-string,
  4. input "P030780",
  5. output bar-code-string). */
  6. Run bar-code-39 (input input-string,
  7. input "P0205075",
  8. output bar-code-string).
  9. OUTPUT TO '\\DWKRFS001\HBKRPR049' PAGED PAGE-SIZE 200 NO-MAP NO-CONVERT.
  10. Put control bar-code-string.
  11. PUT CONTROL CHR(10).
  12. OUTPUT CLOSE.
  13. /* Create bar-code-stringcode, 39 for HP
  14. ** Original code posted on Peg by Joern Winther
  15. ** Adapted by Arthur Fink
  16. **
  17. ** The procedure creates ESC-sequences for a bar-code-stringcode in
  18. ** Code39 format
  19. ** The printer cursor position is restored after printing.
  20. **
  21. ** Input: input-string as char no-undo. The char string to translate.
  22. ** code-spec as char no-undo. The bar-code spec. see later
  23. **
  24. ** Output: bar-code-string as char no-undo. The generated bar-code-stringcode
  25. **
  26. **
  27. ** Structure of code-spec:
  28. ** 1. P for horizontal bar-code
  29. ** L for vertical bar-code
  30. ** 2-3 width of small bar-codes and spaces in dots (norm 03)
  31. ** 4-5 width of wide bar-code and spaces in dots (norm 07-08)
  32. ** 6- Height of bar-code in dots (norm 80)
  33. */
  34. Procedure bar-code-39:
  35. def input parameter input-string as char no-undo.
  36. def input parameter code-spec as char no-undo.
  37. def output parameter bar-code-string as char no-undo.
  38. def var clr as log init true no-undo.
  39. def var wk as char no-undo.
  40. def var drw as char no-undo.
  41. def var dir as char no-undo.
  42. def var k as char no-undo.
  43. def var att as char no-undo.
  44. def var kod as char no-undo
  45. init "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ.? *$/+%".
  46. att =
  47. "100100001001100001101100000000110001100110000001110000000100101100100100"
  48. + "001100100000110100100001001001001001101001000000011001100011000001011000"
  49. + "000001101100001100001001100000011100100000011001000011101000010000010011"
  50. + "100010010001010010000000111100000110001000110000010110110000001011000001"
  51. + "111000000010010001110010000011010000010000101110000100011000100010010100"
  52. + "010101000010100010010001010000101010".
  53. def var i as int no-undo.
  54. def var j as int no-undo.
  55. def var l as int no-undo.
  56. def var brd as int no-undo.
  57. def var jst as int no-undo.
  58. assign
  59. i = if substring (code-spec, 1, 1) = "P" then 1 else 2
  60. bar-code-string = "~E&f0S~E*c100G"
  61. drw = substring ("ab", i, 1)
  62. + substring (code-spec, 6)
  63. + substring ("ba", i, 1) + "P"
  64. dir = substring ("XY", i, 1)
  65. k = "*" + input-string + "*"
  66. .
  67. do i = 1 to length (k):
  68. assign
  69. j = index (kod, substring (k, i, 1)) * 9 - 8
  70. wk = substring (att, j, 9) + "0"
  71. .
  72. do l = 1 to 10:
  73. assign
  74. brd = if substring(wk,l,1) = "0" then 2 else 4
  75. bar-code-string = bar-code-string
  76. + (if clr then "~E*c" + substring (code-spec, brd, 2) + drw
  77. else "~E*p+" + string (integer (substring (code-spec, brd, 2))
  78. + jst) + dir)
  79. jst = integer (substring (code-spec, brd, 2))
  80. clr = not clr
  81. .
  82. end. /* of looping 1 to 10 */
  83. end. /* of going through string 'k' */
  84. assign
  85. bar-code-string = bar-code-string + "~E&f1S"
  86. wk = ""
  87. .
  88. end.