这一段代码来自sdta楼主的一个程序:
SELECT *,00 ZW,00 座位号 FROM 座位表 WHERE .T. INTO CURSOR TT READWRITE
SELECT KCH FROM 座位表 GROUP BY 1 INTO CURSOR T
SELECT T
SCAN
SELECT TT
LOCATE FOR ALLTRIM(ZKZH)==ALLTRIM(T.KCH)+[01]
IF FOUND()
INSERT BEFORE BLANK
REPLACE ZKZH WITH ALLTRIM(T.KCH)+[00],KC WITH RIGHT(ALLTRIM(T.KCH),2)
ENDIF
LOCATE FOR ALLTRIM(ZKZH)==ALLTRIM(T.KCH)+[30]
IF FOUND()
INSERT BLANK
REPLACE ZKZH WITH ALLTRIM(T.KCH)+[31],KC WITH RIGHT(ALLTRIM(T.KCH),2)
ENDIF
SELECT T
ENDSCAN
SELECT TT
GO TOP
REPLACE ALL ZW WITH CAST(RIGHT(ALLTRIM(ZKZH),2) AS N(2))
REPLACE 座位号 WITH ZW+25 FOR BETWEEN(ZW,0,7)
REPLACE 座位号 WITH 32-ZW FOR BETWEEN(ZW,8,15) &&OR BETWEEN(ZW,24,30)
REPLACE 座位号 WITH ZW-7 FOR BETWEEN(ZW,16,23)
REPLACE 座位号 WITH 32-ZW FOR BETWEEN(ZW,24,31)
INDEX ON KC+STR(座位号,2) TO ZWH
REPORT FORM 座位表.FRX NOCONSOLE PREVIEW