程序代码:
CLOSE DATABASES
SET COLLATE TO "MACHINE"
CREATE CURSOR t1 (nj c(6), bj c(7), xm c(10), km c(6), ks n(4), bs n(1))
USE ksjh IN 0 ALIAS ks
SELECT ks
INDEX on nj TAG nj
USE jsrkb20190201 IN 0 ALIAS rkb
SELECT rkb
SCAN
FOR lnj = 3 TO FCOUNT()
lcxm = EVALUATE(FIELD(lnj))
lckm = FIELD(lnj)
IF SEEK(rkb.nj, "ks", "nj") = .T.
lnks = EVALUATE("ks." + lckm)
lnbs = RECNO("ks")
ENDIF
IF NOT EMPTY(lcxm)
INSERT INTO t1 VALUES (rkb.nj, rkb.bj, lcxm, lckm, lnks, lnbs)
ENDIF
ENDFOR
ENDSCAN
SELECT ks
SET ORDER TO
***
CREATE CURSOR t2 (xm c(10), kmnr c(254), ks n(4))
INSERT INTO t2 (xm ) SELECT DISTINCT xm FROM t1
REPLACE kmnr WITH ALLTRIM(xm) + ":" ALL
INDEX ON xm TAG xm
***
SELECT t1
SET RELATION TO xm INTO t2
SCAN
REPLACE kmnr WITH kmnr - t1.nj - t1.bj - t1.km - "|", ks WITH ks + t1.ks IN t2
ENDSCAN
SELECT t2
SET ORDER TO
REPLACE kmnr WITH LEFT(kmnr, LEN(ALLTRIM(kmnr)) - 1) ALL
BROWSE
COPY TO 课程分工.TXT FIELDS kmnr, ks DELIMITED WITH "" WITH CHARACTER TAB