回复 21楼 sdta
CLOSE DATABASES ALL
SET SAFETY OFF
SET DEFAULT TO C:\Users\xqb\Desktop\世行程序
SELECT *,0000 标记,SPACE(10) 村1,SPACE(10) 建设年度1,SPACE(10) 标段1 FROM clf INTO TABLE Test
cDkh = ""
ncun = ""
njsnd = ""
nbdh = ""
SCAN
IF NOT EMPTY(地块号)
REPLACE 标记 WITH VAL(地块号)
replace 村1 WITH 村
replace 建设年度1 WITH 建设年度
replace 标段1 WITH 标段
cDkh = 地块号
ncun = 村
njsnd = 建设年度
nbdh = 标段
ELSE
REPLACE 标记 WITH VAL(cDkh)
REPLACE 村1 WITH ncun
replace 建设年度1 WITH njsnd
replace 标段1 WITH nbdh
ENDIF
ENDSCAN
SELECT clf
cZdm = ""
FOR nCnt = 1 TO AFIELDS(Azdm)
cZdm = cZdm + "," + Azdm[nCnt, 1]
ENDFOR
cZdm = SUBSTR(cZdm, 2)
SELECT DISTINCT 标记,村1,建设年度1,标段1 FROM Test INTO CURSOR T_dist
SCAN
SELECT Test
COPY TO ( ALLTRIM(T_dist.建设年度1) + "年-" + ALLTRIM(T_dist.标段1) + "标段" + ALLTRIM(T_dist.村1) + PADL(T_dist.标记, 4, "0") + "号地块") TYPE XL5 FIELDS &cZdm FOR 标记 = T_dist.标记 AND 村1 = T_dist.村1
ENDSCAN
USE IN Test
ERASE Test.Dbf
最终改成这样达到了我的预期
,谢谢版主的帮助
[此贴子已经被作者于2018-9-17 18:52编辑过]