代码是用VFP9写的
TEMP3是空表
CLEAR SET SAFETY OFF SELECT * FROM TEMP1 WHERE .F. INTO TABLE TEMP3 SELECT RECNO() N FROM TEMP1 WHERE VAL(序号)=1 INTO TABLE TT INSERT INTO TT VALUES (RECCOUNT("temp1")+1) SELECT TT GO TOP N1=N SCAN FOR RECNO()>1 SELECT temp1 COPY TO temp4 FOR VAL(编号)>=N1 AND VAL(编号)<TT.N SELECT temp3 APPEND FROM temp2 APPEND FROM temp4 N1=TT.N ENDSCAN SELECT TEMP3 BROWSE CLOSE DATABASES ERASE TEMP3.DBF ERASE TT.DBF
CLEAR CLOSE DATABASES SET SAFETY OFF USE TEMP2 IN 0 SELECT * FROM TEMP1 WHERE .F. INTO TABLE TEMP3 SELECT RECNO() N FROM TEMP1 WHERE VAL(序号)=1 INTO TABLE TT INSERT INTO TT VALUES (RECCOUNT("temp1")+1) SELECT TT GO TOP N1=N M=0 SCAN FOR RECNO()>1 M=M+1 SELECT temp2 COPY TO ARRAY atemp2 FOR RECNO()=M SELECT temp1 COPY TO temp4 FOR VAL(编号)>=N1 AND VAL(编号)<TT.N SELECT temp3 INSERT INTO temp3 FROM ARRAY atemp2 APPEND FROM temp4 N1=TT.N ENDSCAN SELECT TEMP3 BROWSE CLOSE DATABASES ERASE TEMP3.DBF ERASE TT.DBF