帮忙优化代码
对表中每个字段连续出现的值,依次斌顺序值:程序代码:
create cursor b1 (jnh N(2),m1 c(3),m2 c(3),m3 c(3)) insert into b1 values (1,"M1","","M3") insert into b1 values (2,"","M2","") insert into b1 values (3,"M1","","M3") insert into b1 values (4,"","M2","") insert into b1 values (5,"M1","","M3") insert into b1 values (6,"M1","","M3") insert into b1 values (7,"M1","","") insert into b1 values (8,"","M2","") insert into b1 values (9,"M1","","M3") insert into b1 values (10,"M1","","M3") insert into b1 values (11,"M1","","M3") insert into b1 values (12,"M1","","M3") insert into b1 values (13,"M1","","") insert into b1 values (14,"","M2","") dxcount=Afields(dxarray) For j=2 To dxcount Select b1 Select jnh,&dxarray(j,1) From b1 Where Not !Empty(&dxarray(j,1)) Into Cursor ls nxs=Reccount() If nxs>0 Dimension qs(nxs) Else Select ls Use Loop Endif For p=1 To nxs &&存储某类qsz段 Go p Store jnh To qs(p) Endfor Select ls Use Select b1 Calculate Max(qs(nxs)) To qsmax For mm=1 To nxs If mm=1 Set Filter To jnh<qs(mm) And !Empty(&dxarray(j,1)) Endif If mm<>1 Set Filter To jnh>qs(mm-1) And jnh<=qs(mm) And !Empty(&dxarray(j,1)) Endif Count To jns Go top For kk=1 To jns Replace &dxarray(j,1) With Alltrim(Str(kk)) Skip Endfor Endfor Set Filter To jnh>qsmax And !Empty(&dxarray(j,1)) Count To jns Go top For kk=1 To jns Replace &dxarray(j,1) With Alltrim(Str(kk)) Skip Endfor Endfor Select b1 Set Filter To Brow
这段代码循环太多,对多字段、多记录运行太慢,能否优化一下,谢谢!