回复 27楼 TZTJ
先整理好一个表直接列印是不是较容易些?
模拟数据试试,不知是不是这意思。
图片附件: 游客没有浏览图片的权限,请
登录 或
注册
程序代码:
n级 = 6
n班 = 10
n行 = 8
n列 = 8
* 模拟数据
CREATE CURSOR 学生表 (级 I, 班 I, 名 C(20))
FOR i = 1 TO n级
FOR j = 1 TO n班
FOR k = 1 TO IIF(MOD(i, 2)==0, 60, 50)
*FOR k = 1 TO IIF(MOD(j, 2)==0, 60, 50)
INSERT INTO 学生表 VALUES (i, j, PADL(i,2," ")+"年级"+PADL(j,2," ")+"班"+PADL(k,8,"x"))
ENDFOR
ENDFOR
ENDFOR
cCmd = "CREATE CURSOR 考场表 (考场 I"
FOR i = 1 TO n列
cCmd = cCmd + ",列"+TRANSFORM(i)+" C(20)"
ENDFOR
cCmd = cCmd + ")"
EXECSCRIPT(cCmd)
n场i = 1
n列i = 1
n行i = 0
FOR i = 1 TO n级
建考场表(i, @n场i, @n列i, @n行i)
n列i = IIF(n列i==1, 2, 1)
ENDFOR
SELECT 考场表
GO TOP
BROWSE
FUNCTION 建考场表(n级i, n场i, n列i, n行i)
LOCAL i, n列k, n行k
SELECT * FROM 学生表 WHERE 级==n级i INTO CURSOR 级表
SELECT 级表
INDEX on RAND(班+RECNO()) TAG 班序 && 乱序
GO TOP IN "级表"
n列k = n列i
n行k = n行i
DO WHILE !EOF("级表")
IF n列k > n列
n行k = n行k + n行
IF (n行k+1) <= RECCOUNT("考场表")
n列k = n列i
ELSE
n场i = n场i + 1 && 新场
IF n列i = 2
n行i = n行k
ENDIF
n列i = 1
n列k = n列i
ENDIF
ENDIF
* 写一列
i = 1
DO WHILE !EOF("级表") AND (i <= n行)
IF (n行k+i) <= RECCOUNT("考场表")
GO (n行k+i) IN "考场表"
ELSE
APPEND BLANK IN "考场表"
REPLACE 考场 WITH n场i IN "考场表"
ENDIF
REPLACE ("列"+TRANSFORM(n列k)) WITH 级表.名 IN "考场表"
i = i + 1
SKIP IN "级表"
ENDDO
n列k = n列k + 2
ENDDO
ENDFUNC