程序代码:
CLOSE DATABASES
CREATE CURSOR tjb (班级 C(4),A1 N(4), B1 N(4), C1 N(4), D1 N(4), 总分 N(4))
INSERT INTO tjb (班级) SELECT DISTINCT 班级 FROM cpb
INDEX ON 班级 TAG bj
SELECT cpb
SET RELATION TO 班级 INTO tjb
ALINES(la1, "A,B,C,D", ",")
ALINES(la2, "20,18,12,8", ",")
SCAN
FOR ln1 = 2 TO FCOUNT()
lc1 = ALLTRIM(EVALUATE(FIELD(ln1)))
FOR ln2 = 1 TO LEN(lc1)
lc2 = SUBSTR(lc1, ln2, 1)
IF FOUND("tjb")
REPLACE (lc2 + "1") WITH EVALUATE(lc2 + "1") + 1, 总分 WITH 总分 + VAL(la2[ASCAN(la1, lc2)]) IN tjb
ENDIF
ENDFOR
ENDFOR
ENDSCAN
SET RELATION TO
SELECT tjb
BROWSE