CONST alNone = 0
CONST alTop = 1
CONST alBottom = 2
CONST alLeft = 3
CONST alRight = 4
CONST alClient = 5
CONST crHSplit = -14
CONST crVSplit = -15
$INCLUDE "dbtools.inc"
$INCLUDE "dbt.inc"
$INCLUDE "dbase.inc"
DECLARE SUB readtable
IF COMMANDCOUNT = 1 THEN
dbopen(COMMAND$(1), fmOpenRead)
ELSE
SHOWMESSAGE "Syntax: Browser tablename"
END
END IF
recs% = 200
CREATE frame AS QFORM
Height = 350
center
CAPTION = "Table browser"
Visible = 1
Visible = 0
CREATE Panel AS QPANEL
Align = alTop
Height = 100
CAPTION = "Click to load"
OnClick = readTable
END CREATE
CREATE Splitter AS QSPLITTER
Align = alTop
Cursor = crVSplit
Height = 10
END CREATE
CREATE browse AS QSTRINGGRID
Align = alClient
colcount = fCount()
rowcount = recs%+1
END CREATE
onClose = dbclose
END CREATE
frame.SHOWMODAL
SUB readTable
lonheader%=0
lonStr% = 0
DIM __r AS VARIANT
SHOWMESSAGE "Browsing table..."
FOR i% = 1 TO browse.colcount
__name$ = fieldname(i%)
browse.cell(i%-1,0 ) = __name$
lonHeader% = LEN(__name$)
lonStr% = LengthOf( __name$ )
browse.colWidths(i%-1) = frame.TextWidth( _
STRING$(IIF(lonStr%>=lonheader%, lonStr%, lonheader%), "D"))
FOR j&=1 TO recs%
dbgoto(j&)
panel.CAPTION = "Rec# : " + STR$(recno()) + " Column ->" +STR$(i%)
panel.repaint
__r = fieldget(i%)
SELECT CASE TypeOf(__name$)
CASE "C"
browse.cell(i%-1, j&) = __r
CASE "D"
browse.cell(i%-1, j&) = __r
CASE "N"
DEC? = decimalsOf(__name$)
browse.cell(i%-1, j&) = Format$("%"+STR$(lonStr%)+"."+STR$(DEC?)+"f", __r)
CASE "M"
browse.cell(i%-1, j&) = "Memo"
CASE "L"
browse.cell(i%-1, j&) = IIF(__r = FALSE, "F", "T")
END SELECT
NEXT
NEXT
panel.CAPTION = "Loaded " & STR$(recs%) & " records.."
panel.repaint
END SUB
|