📄 brarray.prg
字号:
#DEFINE OBJECT_CAPTION "(Object)"
LPARAMETERS taArray, tlKeepOpen
ASSERT VARTYPE(taArray[1]) # "U" MESSAGE "You must pass an array to this method"
LOCAL lnSelect, lcCursor, lnRows, lnCols, lnCnt, lcCreate, lcWidth, lnRowCnt, lcInsert, lcColList, lcVal
LOCAL lnMaxWidth
lnSelect = SELECT(0)
SELECT 0
lcCursor = "crs" + RIGHT(SYS(2015), 7)
lnRows = ALEN(taArray, 1)
lnCols = MAX(1, ALEN(taArray, 2))
* Add the row # column
lcCreate = "CREATE CURSOR " + lcCursor + " (RowNum N(4,0), "
lcColList = "RowNum, "
FOR lnCnt = 1 TO lnCols
lnMaxWidth = 1
FOR lnRowCnt = 1 TO lnRows
IF VARTYPE(taArray[lnRowCnt, lnCnt]) = "O"
lnWidth = LEN(OBJECT_CAPTION)
ELSE
lnWidth = LEN(TRANS(taArray[lnRowCnt, lnCnt]))
ENDIF
lnMaxWidth = MAX(lnWidth, lnMaxWidth)
ENDFOR
lcWidth = TRANS(lnMaxWidth)
lcCol = "Col" + TRANS(lnCnt)
lcCreate = lcCreate + lcCol + " C(" + lcWidth + ")" + IIF(lnCnt = lnCols, "", ", ")
lcColList = lcColList + lcCol + IIF(lnCnt = lnCols, "", ", ")
ENDFOR
lcCreate = lcCreate + " )"
&lcCreate
FOR lnRowCnt = 1 TO lnRows
lcInsert = "INSERT INTO " + lcCursor + " (" + lcColList + " ) VALUES (" + TRANSFORM(lnRowCnt) + ", "
FOR lnCnt = 1 TO lnCols
IF VARTYPE(taArray[lnRowCnt, lnCnt]) = "O"
lcVal = "[" + OBJECT_CAPTION + "]"
ELSE
lcVal = "[" + TRANS(taArray[lnRowCnt, lnCnt]) + "]"
ENDIF
lcInsert = lcInsert + lcVal + IIF(lnCnt = lnCols, "", ", ")
ENDFOR
lcInsert = lcInsert + ")"
&lcInsert
ENDFOR
IF USED(lcCursor)
LOCATE
IF tlKeepOpen
BROWSE NORMAL NOWAIT
ELSE
BROWSE NORMAL
USE IN (lcCursor)
ENDIF
ENDIF
SELECT (lnSelect)
RETURN
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -