首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > VFP >

这个code39码如何用啊

2013-07-08 
这个code39码怎么用啊?从网上下了一个老师的一段代码,生成code39码的,可以在命令窗口中使用,如“code39(A

这个code39码怎么用啊?
从网上下了一个老师的一段代码,生成code39码的,可以在命令窗口中使用,如“=code39('ABCD1234','10','条码1.bmp')”,现在我想用一个循环,比如生成“ABCD0001~ABCD0999”之间的条码,不会用啊,在此请教各位了。
原代码如下:

*function code39
para chrs01,bars_h,bmp_filename     &&输入条码字符,条码高度,生成文件的文件名
private c001,chrs01
dimension sys_code39(2,44)
sys_code39(1,1)='0'
sys_code39(2,1)='101001101101'   && 字符0
sys_code39(1,2)='1'
sys_code39(2,2)='110100101011'   && 字符1
sys_code39(1,3)='2'
sys_code39(2,3)='101100101011'   && 字符2
sys_code39(1,4)='3'
sys_code39(2,4)='110110010101'   && 字符3
sys_code39(1,5)='4'
sys_code39(2,5)='101001101011'   && 字符4
sys_code39(1,6)='5'
sys_code39(2,6)='110100110101'   && 字符5
sys_code39(1,7)='6'
sys_code39(2,7)='101100110101'   && 字符6
sys_code39(1,8)='7'
sys_code39(2,8)='101001011011'   && 字符7
sys_code39(1,9)='8'
sys_code39(2,9)='110100101101'   && 字符8
sys_code39(1,10)='9'
sys_code39(2,10)='101100101101'   && 字符9
sys_code39(1,11)='A'
sys_code39(2,11)='110101001011'   && 字符A
sys_code39(1,12)='B'
sys_code39(2,12)='101101001011'   && 字符B
sys_code39(1,13)='C'
sys_code39(2,13)='110110100101'   && 字符C
sys_code39(1,14)='D'
sys_code39(2,14)='101011001011'   && 字符D
sys_code39(1,15)='E'
sys_code39(2,15)='110101100101'   && 字符E
sys_code39(1,16)='F'
sys_code39(2,16)='101101100101'   && 字符F
sys_code39(1,17)='G'
sys_code39(2,17)='101010011011'   && 字符G
sys_code39(1,18)='H'
sys_code39(2,18)='110101001101'   && 字符H
sys_code39(1,19)='I'
sys_code39(2,19)='101101001101'   && 字符I
sys_code39(1,20)='J'
sys_code39(2,20)='101011001101'   && 字符J
sys_code39(1,21)='K'
sys_code39(2,21)='110101010011'   && 字符K
sys_code39(1,22)='L'
sys_code39(2,22)='101101010011'   && 字符L
sys_code39(1,23)='M'
sys_code39(2,23)='110110101001'   && 字符M
sys_code39(1,24)='N'
sys_code39(2,24)='101011010011'   && 字符N
sys_code39(1,25)='O'
sys_code39(2,25)='110101101001'   && 字符O
sys_code39(1,26)='P'
sys_code39(2,26)='101101101001'   && 字符P
sys_code39(1,27)='Q'
sys_code39(2,27)='101010110011'   && 字符Q


sys_code39(1,28)='R'
sys_code39(2,28)='110101011001'   && 字符R
sys_code39(1,29)='S'
sys_code39(2,29)='101101011001'   && 字符S
sys_code39(1,30)='T'
sys_code39(2,30)='101011011001'   && 字符T
sys_code39(1,31)='U'
sys_code39(2,31)='110010101011'   && 字符U
sys_code39(1,32)='V'
sys_code39(2,32)='100110101011'   && 字符V
sys_code39(1,33)='W'
sys_code39(2,33)='110011010101'   && 字符W
sys_code39(1,34)='X'
sys_code39(2,34)='100101101011'   && 字符X
sys_code39(1,35)='Y'
sys_code39(2,35)='110010110101'   && 字符Y
sys_code39(1,36)='Z'
sys_code39(2,36)='100110110101'   && 字符Z
sys_code39(1,37)='-'
sys_code39(2,37)='100101011011'   && 字符-
sys_code39(1,38)='.'
sys_code39(2,38)='110010101101'   && 字符.
sys_code39(1,39)=' '
sys_code39(2,39)='100110101101'   && 字符 空格
sys_code39(1,40)='$'
sys_code39(2,40)='100100100101'   && 字符$
sys_code39(1,41)='/'
sys_code39(2,41)='100100101001'   && 字符/
sys_code39(1,42)='+'
sys_code39(2,42)='100101001001'   && 字符+
sys_code39(1,43)='%'
sys_code39(2,43)='101001001001'   && 字符%
sys_code39(1,44)='*'
sys_code39(2,44)='100101101101'   && 字符*

chrs01=allt(chrs01)
c001=''
for n001=1 to len(chrs01)
    c001=c001+'00'+sys_code39(2,ascan(sys_code39,substr(chrs01,n001,1)))
endfor
c001=sys_code39(2,44)+c001+'00'+sys_code39(2,44)

if mod(len(c001),8)=0
   dime chr_n(int(len(c001)/8))
else
   dime chr_n(int(len(c001)/8)+1)
   c001=c001+'0000000'
endif
for n001=1 to int(len(c001)/8)
    chr_n(n001)=255-bar001(substr(c001,(n001-1)*8+1,8))
endfor
=bw_bmp(bmp_filename,alen(chr_n)*8,bars_h,'chr_n')
function bw_bmp

para bmpfilename,biwidth,biheight,dat_arry_name  && 接收参数:图位文件名,图位宽度,图位高度

dime bmp_chrs(31)
private bmpfilename,biwidth,biheight,DataSizePerLine,bmpfilesize,dat_arry_name,n001,n002,n003,n004,add0,bmpfilename,biwidth,biheight,dat_arry_name

bibitcount=1
DataSizePerLine_=biWidth/8                   &&每行为4的倍数,要调整

add0=4-mod(DataSizePerLine_,4)
add0=iif(add0=4,0,add0)

DataSizePerLine=DataSizePerLine_+iif(mod(DataSizePerLine_,4)=0,0,4-mod(DataSizePerLine_,4)) 



DataSize=DataSizePerLine*biHeight

bmp_chrs(1)='BM'

bmp_chrs(15)=chr(1)+chr(0)
bmpfilesize=31*2+DataSize

bmp_chrs(2)=chr(fun10to16(bmpfilesize,1))+chr(fun10to16(bmpfilesize,2))
bmp_chrs(3)=chr(fun10to16(bmpfilesize,3))+chr(fun10to16(bmpfilesize,4))
bmp_chrs(4)=chr(0)+chr(0)
bmp_chrs(5)=chr(0)+chr(0)
bmp_chrs(6)=chr(62)+chr(0)   &&单色是31个字,31X2字节
bmp_chrs(7)=chr(0)+chr(0)

bmp_chrs(8)=chr(40)+chr(0)
bmp_chrs(9)=chr(0)+chr(0)

bmp_chrs(10)=chr(fun10to16(biWidth,1))+chr(fun10to16(biWidth,2))
bmp_chrs(11)=chr(fun10to16(biWidth,3))+chr(fun10to16(biWidth,4))


bmp_chrs(12)=chr(biHeight)+chr(0)
bmp_chrs(13)=chr(0)+chr(0)
bmp_chrs(14)=chr(1)+chr(0)

bmp_chrs(16)=chr(0)+chr(0)
bmp_chrs(17)=chr(0)+chr(0)

bmp_chrs(18)=chr(fun10to16(DataSize,1))+chr(fun10to16(DataSize,2))
bmp_chrs(19)=chr(fun10to16(DataSize,3))+chr(fun10to16(DataSize,4))

bmp_chrs(20)=chr(0)+chr(0)

stor chr(0)+chr(0) to bmp_chrs(20),bmp_chrs(21),bmp_chrs(22),bmp_chrs(23),bmp_chrs(24),bmp_chrs(25),bmp_chrs(26),;
     bmp_chrs(27),bmp_chrs(28),bmp_chrs(29)

bmp_chrs(30)=chr(256-1)+chr(256-1)
bmp_chrs(31)=chr(256-1)+chr(0)

strtofile(bmp_chrs(1),bmpfilename)
for f001=2 to 31
   strtofile(bmp_chrs(f001),bmpfilename,.t.)
endfor

n004=alen(&dat_arry_name)

if n004>=DataSizePerLine_*biHeight
    for n003=1 to biheight
        for n001=1 to DataSizePerLine_
            strtofile(chr(&dat_arry_name((n003-1)*DataSizePerLine_+n001)),bmpfilename,.t.)
        endfor
        for n001=1 to add0
            strtofile(chr(0),bmpfilename,.t.)
        endfor
    endfor
else
    if n004>=DataSizePerLine_
        for n002=1 to biheight
            for n001=1 to DataSizePerLine_
                strtofile(chr(&dat_arry_name(n001)),bmpfilename,.t.)
            endfor    
            for n001=1 to add0
                strtofile(chr(0),bmpfilename,.t.)


            endfor
        endfor
    else

        for n002=1 to biheight

            for n001=1 to n004
                strtofile(chr(&dat_arry_name(n001)),bmpfilename,.t.)
            endfor    
            for n001=1 to DataSizePerLine_-n004+add0
                strtofile(chr(0),bmpfilename,.t.)
            endfor
        endfor
    endif


endif



function fun10to16
para n001,n002
private n001,n002
do case
case n002=1
    retu mod(n001,16*16)
case n002=2
    retu mod(int(n001/(16*16)),16*16)
case n002=3
    retu mod(int(n001/(16*16*16*16)),16*16)
case n002=4
    retu mod(int(n001/(16*16*16*16*16*16)),16*16)
endcase

function bar001
para bar001
private bar001,bat,n001
dime bat(8)
bat(1)=128
bat(2)=64
bat(3)=32
bat(4)=16
bat(5)=8
bat(6)=4
bat(7)=2
bat(8)=1

tota001=0
for n001=1 to 8
   tota001=tota001+val(substr(bar001,n001,1))*bat(n001)
endfor
retu tota001

&& end  &&


[解决办法]
有现成的39码字体
有关在VFP中使用和打印条码(条码字体[39码]和条码控件)
http://download.csdn.net/source/3437169

热点排行