string ls_layer
choose case ai_layer
case 0
ls_layer = "background"
case 1
ls_layer = "foreground"
case 2
ls_layer = "header"
case 3
ls_layer = "detail"
case 4
ls_layer = "summary"
case 5
ls_layer = "footer"
case else
return -1
end choose
下面的函数是从类库中的数据窗口基础服务类中取得,作为datawindow或datastore的基础服务,可在dw中产生条码~
public function integer of_createbarcode_c39 (integer ai_layer, integer ai_x, integer ai_y, integer ai_w, integer ai_h, string as_code, boolean ab_show)
/**********************************************************************
//利用rectangle产生39码
// ai_x,ai_y 为条码的位置
//ai_w 条码窄线的宽度
//ai_h 高度
//as_code 要打印的字符串
//ab_show 是否产生字符
//Create 1999-09-02
//LastModify 2000-03-20
//Author: softfun
/**********************************************************************
string ls_layer
choose case ai_layer
case 0
ls_layer = "background"
case 1
ls_layer = "foreground"
case 2
ls_layer = "header"
case 3
ls_layer = "detail"
case 4
ls_layer = "summary"
case 5
ls_layer = "footer"
case else
return -1
end choose
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 = ai_x
y_scan = ai_y
Bar_Table[1]='00110-0100' // 0
Bar_Table[2]='10001-0100' // 1
Bar_Table[3]='01001-0100' // 2
Bar_Table[4]='11000-0100' // 3
Bar_Table[5]='00101-0100' // 4
Bar_Table[6]='10100-0100' // 5
Bar_Table[7]='01100-0100' // 6
Bar_Table[8]='00011-0100' // 7
Bar_Table[9]='10010-0100' // 8
Bar_Table[10]='01010-0100' // 9
Bar_Table[11]='10001-0010' // A
Bar_Table[12]='01001-0010' // B
Bar_Table[13]='11000-0010' // C
Bar_Table[14]='00101-0010' // D
Bar_Table[15]='10100-0010' // E
Bar_Table[16]='01100-0010' // F
Bar_Table[17]='00011-0010' // G
Bar_Table[18]='10010-0010' // H
Bar_Table[19]='01010-0010' // I
Bar_Table[20]='00110-0010' // J
Bar_Table[21]='10001-0001' // K
Bar_Table[22]='01001-0001' // L
Bar_Table[23]='11000-0001' // M
Bar_Table[24]='00101-0001' // N
Bar_Table[25]='10100-0001' // O
Bar_Table[26]='01100-0001' // P
Bar_Table[27]='00011-0001' // Q
Bar_Table[28]='10010-0001' // R
Bar_Table[29]='01010-0001' // S
Bar_Table[30]='00110-0001' // T
Bar_Table[31]='10001-1000' // U
Bar_Table[32]='01001-1000' // V
Bar_Table[33]='11000-1000' // W
Bar_Table[34]='00101-1000' // X
Bar_Table[35]='10100-1000' // Y
Bar_Table[36]='01100-1000' // Z
Bar_Table[37]='00011-1000' // -
Bar_Table[38]='10010-1000' // %
Bar_Table[39]='01010-1000' // $
Bar_Table[40]='00110-1000' // *
Bar_Card = upper(as_code)
Bar_Print = Bar_Card
if left(bar_card,1) <> '*' then
Bar_Print = '*' + Bar_Card // 添加起始符
end if
if right(bar_card,1) <> '*' then
Bar_Print = Bar_Card + '*' // 添加结束符
end if
j = 1
string ls_modify
integer li_name = 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
ls_modify = 'Create rectangle(band='+ls_layer+' x="'+string(x_scan)+'" y="'+string(y_scan)+'" width="'+string(ai_w)+'" height="'+string( ai_h)+'" name=rect_'+string(li_name)+' visible="1" brush.hatch="6" brush.color="33554432" pen.style="0" pen.width="5" pen.color="33554432" background.mode="2" background.color="33554432" )'
li_name++
idw_requestor.modify(ls_modify)
X_Scan = X_Scan + ai_w
else
ls_modify = 'Create rectangle(band='+ls_layer+' x="'+string(x_scan)+'" y="'+string(y_scan)+'" width="'+string(3*ai_w)+'" height="'+string( ai_h)+'" name=rect_'+string(li_name)+' visible="1" brush.hatch="6" brush.color="33554432" pen.style="0" pen.width="5" pen.color="33554432" background.mode="2" background.color="33554432" )'
li_name++
idw_requestor.modify(ls_modify)
X_Scan = X_Scan + ai_w * 3
end if
if (Temp_Card[6 + i] = '1') then
X_Scan = X_Scan + 4 * ai_w
else
X_Scan = X_Scan + 3 * ai_w /2
end if
if i= 2 and ab_show and Bar_Print[j]<>'*' then
ls_modify = 'Create text(band='+ls_layer+' alignment="0" text="'+Bar_Print[j]+&
'" border="0" color="33554432" x="'+string(x_scan)+'" y="'+string(y_scan + ai_h + 10)+'" width="110" height="60" html.valueishtml="0" '+&
'name=text_'+string(li_name)+' visible="1" font.face="Arial" font.height="-9" font.weight="400" font.family="2" '+&
'font.pitch="2" font.charset="0" background.mode="2" background.color="1073741824" )'
idw_requestor.modify(ls_modify)
end if
next
j = j + 1
loop while (Bar_Print[j] <> '')
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 = ai_xpos
y_scan = ai_ypos
Bar_Table[1]='00110-0100' // 0
Bar_Table[2]='10001-0100' // 1
Bar_Table[3]='01001-0100' // 2
Bar_Table[4]='11000-0100' // 3
Bar_Table[5]='00101-0100' // 4
Bar_Table[6]='10100-0100' // 5
Bar_Table[7]='01100-0100' // 6
Bar_Table[8]='00011-0100' // 7
Bar_Table[9]='10010-0100' // 8
Bar_Table[10]='01010-0100' // 9
Bar_Table[11]='10001-0010' // A
Bar_Table[12]='01001-0010' // B
Bar_Table[13]='11000-0010' // C
Bar_Table[14]='00101-0010' // D
Bar_Table[15]='10100-0010' // E
Bar_Table[16]='01100-0010' // F
Bar_Table[17]='00011-0010' // G
Bar_Table[18]='10010-0010' // H
Bar_Table[19]='01010-0010' // I
Bar_Table[20]='00110-0010' // J
Bar_Table[21]='10001-0001' // K
Bar_Table[22]='01001-0001' // L
Bar_Table[23]='11000-0001' // M
Bar_Table[24]='00101-0001' // N
Bar_Table[25]='10100-0001' // O
Bar_Table[26]='01100-0001' // P
Bar_Table[27]='00011-0001' // Q
Bar_Table[28]='10010-0001' // R
Bar_Table[29]='01010-0001' // S
Bar_Table[30]='00110-0001' // T
Bar_Table[31]='10001-1000' // U
Bar_Table[32]='01001-1000' // V
Bar_Table[33]='11000-1000' // W
Bar_Table[34]='00101-1000' // X
Bar_Table[35]='10100-1000' // Y
Bar_Table[36]='01100-1000' // Z
Bar_Table[37]='00011-1000' // -
Bar_Table[38]='10010-1000' // %
Bar_Table[39]='01010-1000' // $
Bar_Table[40]='00110-1000' // *
Bar_Card = upper(as_code)
Bar_Print = Bar_Card
if left(bar_card,1) <> '*' then
Bar_Print = '*' + Bar_Card // 添加起始符
end if
if right(bar_card,1) <> '*' then
Bar_Print = Bar_Card + '*' // 添加结束符
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 + ai_barwidth / 2
PrintLine(al_job,X_Scan,y_scan,x_Scan,y_scan + ai_h,ai_barwidth)
X_Scan = X_Scan + ai_barwidth / 2
else
X_Scan = X_Scan + ai_barwidth * 3 / 2
//+-6为校正
PrintLine(al_job,X_Scan,y_scan + 6,x_Scan,y_scan + ai_h - 6,3 * ai_barwidth)
X_Scan = X_Scan + ai_barwidth * 3 / 2
end if
if (Temp_Card[6 + i] = '1') then
X_Scan = X_Scan + 4 * ai_barwidth
else
X_Scan = X_Scan + 3 * ai_barwidth /2
end if
if i = 2 and ab_printtext and Bar_Print[j]<>'*' then printtext(al_job,Bar_Print[j],X_scan,y_scan + ai_h +50)
next
j = j + 1
loop while (Bar_Print[j] <> '')