当前位置: 代码迷 >> VFP >> 【VFP】一段程序,那部分复制出来能当独立的身份证核查程序,该如何解决
  详细解决方案

【VFP】一段程序,那部分复制出来能当独立的身份证核查程序,该如何解决

热度:4028   发布时间:2013-02-26 00:00:00.0
【VFP】一段程序,那部分复制出来能当独立的身份证核查程序
程序如下,说明下,运行这个已经可以核查身份证校验码对错,但是一个文本超过100多个的时候,运行会出错,我在想是不是因为这个文本的另个程序模块有300限制而引起的? 
这个程序do一下,直接可以把开户清单.xls(姓名,身份证号)里的身份证号核查并产生一个适合的开户txt文本。因为系统要求,文本里要求数量限制是不能超过300。

set safe off
set talk off
set proc to chd

pkhj='331082002'

use dfgz1 in 1
use newhead in 2
USE newbody IN 3
USE sfzherror IN 4
SELECT sfzherror
ZAP
SELECT dfgz1
zap
appe from 开户清单.xls type xl8
dele for allt(name)=="" or chrtran(name,' ','')=="姓名" or ALLTRIM(sfzh)==''
pack
*去掉身份证中误输入的TAB字符
REPLACE sfzh WITH CHRTRAN(sfzh,' ','') all
COUNT TO totnew
newn=CEILING(totnew/300)


FOR cou=1 TO newn
  *文件头
  SELECT dfgz1
  sum gze to hjgze FOR RECNO()<=300*cou AND RECNO()>300*(cou-1)
  IF cou=newn
  totn=totnew-300*(newn-1)
  ELSE
  totn=300
  ENDIF
  sele newhead
  zap
  appe blank
  ptot=allt(str(totn))
  phjgze=allt(str(hjgze*100))
  repl sxh with pkhj+subs(dtos(date()),3,6)+chd(3-LEN(ALLTRIM(STR(cou))))+ALLTRIM(STR(cou))+'|',;
  jrzs with chd(8-len(ptot))+ptot+'|',zjyje with chd(16-len(phjgze))+phjgze+'|',;
  zywsxf with '000000000000|',zylsxf with '000000000000|',sfwtfh with '00|',wbjglx with '00|',;
  wbjgdm with '00000000000000|',dsffhdm with '000000000|',;
  pth with '00000000000|',zy with space(10)+'|'
  headfname='newhead'+ALLTRIM(STR(cou))+'.txt'
  copy to &headfname type sdf  
  *文件体
  sele newbody
  zap
  sele dfgz1
  go 300*(cou-1)+1
  nn=0
  do whil !EOF() AND nn<300
  nn=nn+1
  pnn=allt(str(nn))
  pname=chrtran(name,' ','')
  pgze=allt(str(gze*100))
  IF LEN(ALLTRIM(sfzh))=18
  IF SUBSTR(ALLTRIM(sfzh),18,1)='x'
  REPLACE sfzh WITH SUBSTR(ALLTRIM(sfzh),1,17)+'X'
  ENDIF
  ENDIF
  psfzh=allt(sfzh)
  *核查身份证
  pcheck=checkidno(psfzh)
  IF psfzh<>pcheck
  SELECT sfzherror
  APPEND BLANK
  REPLACE name WITH pname,sfzh WITH psfzh,checkend WITH pcheck
  ENDIF
  sele newbody
  appe blank
  repl num with chd(8-len(pnn))+pnn+'|',name with pname+space(22-len(pname)),;
  bz with '|01|',sfzh with psfzh+space(18-len(psfzh))+'|',gze with chd(12-len(pgze))+pgze+'|',;
  fzjg with space(26)+'3456|'
  sele dfgz1 
  skip
  endd  
  sele newbody
  bodyfname='newbody'+ALLTRIM(STR(cou))+'.txt'
  copy to &bodyfname type sdf
  *合并
  newfname='new'+substr(dtos(date()),3,6)+ALLTRIM(STR(cou))+'.txt'
  a=FILETOSTR("&headfname")
  b=FILETOSTR("&bodyfname")
  STRTOFILE(a+b,"&newfname")
ENDFOR

SELECT sfzherror
COUNT TO toterr
IF toterr<>0
  COPY TO sfzherror.txt deli WITH tab
  aa=FILETOSTR('sfzherror.txt')
  aa=STRTRAN(aa,["],'')
  STRTOFILE(aa,'sfzherror.txt')
ENDIF

clos all

*核对身份证函数
FUNCTION checkidno
PARAMETERS idnumber

LOCAL checknum,i,m,temp1,temp2,temp3

IF LEN(idnumber)=15 OR LEN(idnumber)=18
  IF LEN(idnumber)=15
  m=0
  FOR i=1 TO 15
  IF !ISDIGIT(SUBSTR(idnumber,i,1))
  相关解决方案