With the increasing application of computers in production, sales, and management, and the popularization of Internet and Intranet, bar code technology is increasingly used in production management and sales management, bar code encoding and recognition technologies have also developed rapidly. Due to the need to build an information management system, our company uses bar codes to identify optical fiber cables in production and manage optical fiber cables. We need to provide bar code printing functions for multiple clients. However, regular bar code printers are expensive and have a single function. It is not cost-effective to assign bar code printers to each computer, and it also brings inconvenience to the work.
---- We used PowerBuilder 6.0, a front-end development tool of MIS system, to design a set of programs and print the bar code on a common laser printer, which successfully solved the bar code problem in production management.
---- Currently, the code encoding is usually 39 codes, which can be seen everywhere on everyday products. It includes the identification code and the difference between the start and end of a '*' bar code. The encoding method is, the encoding of each character is expressed by the gap between the five black lines and the adjacent black lines. The black line of the width indicates 1, the narrow line indicates 0, the gap width between the black lines indicates 1, and the narrow line indicates 0. Such a 9-bit binary number is used to represent a character. For example, 001100100 (the first five digits are represented by a line, and the last four digits are spaces) indicates the decimal 0. In the 39-digit rule, three digits must be 1 in 9 digits. According to this rule, the 26 letters, 10 digits, and some commonly used symbols on the keyboard are all individually matched with 39 codes. We use this rule for program design.
---- Powerbuilder provides a printline () function:
---- PrintLine (printjobnumber, x1, y1, x2, y2, thickness) can print multiple straight lines in a printjobnumber. The line position is determined by the specified coordinate, and the line width is determined by Thickness, in this way, the program can implement our predefined functions.
---- Define a function in PB, for example, window function:
Wf_barprint (long job, integer x_pos,
Integer y_pos, bar_width as intger, string code)
Returns integer
// X_pos and y_pos are the start position of bar code printing.
// Bar_Width: the width of the narrow bar code.
// Code, the string to be printed
Char Bar_Card [20], Bar_Print [22]
Char Temp_Card [12]
String Bar_Table [40]
Int I, j, X_Scan, Cal_Card, y_scan
X_scan = x_pos
Y_scan = y_pos
Bar_Table [1] = '2014-00110 '// 0
Bar_Table [2] = '2014-10001 '// 1
Bar_Table [3] = '2014-01001 '// 2
Bar_Table [4] = '2014-11000 '// 3
Bar_Table [5] = '2014-00101 '// 4
Bar_Table [6] = '2014-10100 '// 5
Bar_Table [7] = '2014-01100 '// 6
Bar_Table [8] = '2014-00011 '// 7
Bar_Table [9] = '2014-10010 '// 8
Bar_Table [10] = '2014-01010 '// 9
Bar_Table [11] = '2014-10001 '//
Bar_Table [12] = '2014-01001 '// B
Bar_Table [13] = '2014-11000 '// C
Bar_Table [14] = '2014-00101 '// D
Bar_Table [15] = '2014-10100 '// E
Bar_Table [16] = '2014-01100 '// F
Bar_Table [17] = '2014-00011 '// G
Bar_Table [18] = '2014-10010 '// H
Bar_Table [19] = '2014-01010 '// I
Bar_Table [20] = '2014-00110 '// J
Bar_Table [21] = '2014-10001 '// K
Bar_Table [22] = '2014-01001 '// L
Bar_Table [23] = '2014-11000 '// M
Bar_Table [24] = '2014-00101 '// N
Bar_Table [25] = '2014-10100 '// O
Bar_Table [26] = '2014-01100 '// P
Bar_Table [27] = '2014-00011 '// Q
Bar_Table [28] = '2014-10010 '// R
Bar_Table [29] = '2014-01010 '// S
Bar_Table [30] = '2014-00110 '// T
Bar_Table [31] = '2014-10001 '// U
Bar_Table [32] = '2014-01001 '/V
Bar_Table [33] = '2014-11000 '// W
Bar_Table [34] = '2014-00101 '// X
Bar_Table [35] = '2014-10100 '// Y
Bar_Table [36] = '2014-01100 '// Z
Bar_Table [37] = '2014-00011 '//-
Bar_Table [38] = '2014-10010 '// %
Bar_Table [39] = '2014-01010 '// $
Bar_Table [40] = '2014-00110 '//*
Bar_Card = upper (code)
If left (bar_card, 1) <> '*' then
Bar_Print = '*' + Bar_Card // Add the start character.
End if
If right (bar_card, 1) <> '*' then
Bar_Print = Bar_Card + '*' // Add the Terminator
End if
J = 1
Do
If (Bar_Print [j] = '*') then
Cal_Card = 40
Elseif (Bar_Print [j] = '-') then
Cal_Card = 37
Elseif (Bar_Print [j]> = 'A') then
Cal_Card = 11 + asc (Bar_Print [j])
-Asc ('A ')
Elseif (bar_print [J]> = '0') then
Cal_card = 1 + ASC (bar_print [J])
-ASC ('0 ')
End if
Temp_card = bar_table [cal_card]
For I = 1 to 5
If (temp_card [I] = '0') then
X_scan = x_scan + bar_width/2
Printline (job, x_scan, y_scan,
X_scan, y_scan + 550, bar_width)
X_scan = x_scan + bar_width/2
Else
X_scan = x_scan + barriers * width * 3/2
Printline (job, x_scan, y_scan + 6,
X_scan, y_scan + 544,3 * bar_width)
X_scan = x_scan + barriers * width * 3/2
End if
If (temp_card [6 + I] = '1') then
X_scan = x_scan + 4 * bar_width
Else
X_scan = x_scan + 3 * bar_width/2
End if
Next
J = J + 1
Loop while (bar_print [J] <> '')
Printtext (job, code, x_scanning-1200, y_scan + 600)
Return 1
---- Call the preceding udfs and printbitmap (printjobnumber, bitmap, X, Y, width, height), printtext () with other functions, you can easily print beautiful bar codes and secondary patterns on a common laser printer. The reason why printjobnumber is directly determined during the call is to print the report and bar code in one piece of paper under the same printjobnumber when the report is generated. This makes your report very professional, and pretty.