你用TEXT1存放矩阵的行数(表1.DBF的记录总数),用TEXT2存放矩阵的列数(表1.DBF的字段数),GRID1显示表1.DBF的内容,COMMAND1为"修改表结构",COMMAND2为"结束",
(1)FORM1.INIT()
CLOSE ALL
IF FILE("表1.DBF")
USE 表1.DBF
ELSE
CREATE TABLE 表1 (列1 N(12,4),列2 N(12,4))
APPEND BLANK
REPLACE 列1 WITH 0,列2 WITH 0
ENDIF
THISFORM.GRID1.RECORDSOURCETYPE=6
THISFORM.GRID1.COLUMNCOUNT=-1
THISFORM.GRID1.RECORDSOURCE="表1"
THISFORM.TEXT1.value=RECCOUNT()
THISFORM.TEXT2.value=FCOUNT()
(2)COMMAND1.CLICK()
THISFORM.GRID1.RECORDSOURCE=NULL
M=THISFORM.TEXT1.value
N=THISFORM.TEXT2.value
*修改矩阵的行数
DO CASE
CASE M<=0
THISFORM.TEXT1.value=RECCOUNT()
CASE M=RECCOUNT()
CASE M>RECCOUNT()
DO WHILE M>RECCOUNT()
APPEND BLANK
ENDDO
CASE M<RECCOUNT()
DELETE ALL FOR RECNO()>M
PACK
ENDCASE
*修改矩阵的列数
DO CASE
CASE N<=0
THISFORM.TEXT1.value=FCOUNT()
CASE N=FCOUNT()
CASE N>FCOUNT()
DO WHILE N>FCOUNT()
FN="列"+ALLTRIM(STR(FCOUNT()+1))
ALTER TABLE 表1 ADD (FN) N(12,4)
ENDDO
CASE N<FCOUNT()
DO WHILE N<FCOUNT()
FN="列"+ALLTRIM(STR(FCOUNT()))
ALTER TABLE 表1 DROP (FN)
ENDDO
ENDCASE
THISFORM.GRID1.RECORDSOURCE="表1"
THISFORM.REFRESH
(3)COMMAND2.CLICK()
THISFORM.RELEASE