共24条记录
代码如下
程序代码:
Get(3, 2, "a", "1")
Get(4, 3, "c", "2")
Create Table b1 (m1 C(2),m2 C(2),m3 C(2),m4 C(2),m5 C(2),m6 C(2))
FOR lnk = 1 TO 2
SELECT temp1
SCAN
SELECT temp2
SCAN
INSERT INTO b1 VALUES (temp1.S01, temp1.S02, "b" + STR(lnk, 1), temp2.S01, temp2.S02, temp2.S03)
ENDSCAN
ENDSCAN
ENDFOR
SELECT b1
BROWSE
RETURN
*
FUNCTION Get(ln1, ln2, lc1, lc2)
* 说明
* 数据范围:ln1
* 列数范围:ln2
* ln1 > ln2
CREATE CURSOR t1 (hm C(2))
FOR lnj = 1 TO ln1
INSERT INTO t1 VALUES (lc1 + TRANSFORM(lnj))
ENDFOR
*
cStr = ""
cField = ""
cFrom = ""
cOrder = ""
cSql = ""
cWhere = ""
FOR lnj = 1 TO ln2
cStr = "S" + PADL(lnj, 2, "0")
cField = cField + IIF(EMPTY(cField), "", ", ") + cStr + ".hm As " + cStr
cFrom = cFrom + IIF(EMPTY(cFrom), "", ", ") + "t1 " + cStr
cWhere = cWhere + cStr + ".hm" + " AND " + cStr + ".hm < "
cOrder = cOrder + IIF(EMPTY(cOrder), " ", ", ") + TRANSFORM(lnj)
ENDFOR
cWhere = SUBSTR(cWhere, 12, LEN(cWhere) - 25)
cSql = "SELECT " + cField + " FROM " + cFrom + " WHERE " + cWhere + " ORDER BY " + cOrder + " INTO CURSOR temp" + lc2
EXECSCRIPT(cSql)
ENDFUNC