Example MDBDUMP.PRT
; MDBDUMP
;
; Program for Proteus
;
; (C) 2003-2004 Simone Zanella Productions
;
; This program displays the contents of all the tables included in the database
; specified as the first parameter.

#!proteus -z -j

!include "daodefs.prt"

IF LT(ARGC, 5)
  CONSOLELN "Syntax: " ARGV(1) " " ARGV(2) \
            " filename.mdb"
  CONSOLELN "Write the contents of the tables inside filename.mdb"
  ABORT 0
FI

; Open database
DBHandle = 0
OpenDB(@DBHandle, ARGV(5))

; Browse all tables
NumTab = DAODBGETTABCOUNT(DBHandle)
FOR X = 1 TO NumTab
  V = DAODBGETTABINFO(DBHandle, X) 
  TabName = VECGET(V, 1)
  VECFREE(V)
  IF STRNEQ(LEFT(TabName, 4), "MSys")
    CONSOLELN "Table: " TabName
    CONSOLELN ""
    rshandle = 0
    ; Print the contents of the table
    IF OpenTable(DBHandle, @rshandle, TabName)  
      PrintRecord(rshandle)  
      DAORSCLOSE(rshandle)
      DAORSFREE(rshandle)
    FI
  FI
NEXT  
DAODBCLOSE(DBHandle)
DAODBFREE(DBHandle)

ABORT 0


FUNCTION OpenDB(dbhandle, s)

; Allocate database and try to open it; store into dbhandle its handle
dbhandle = DAODBNEW()

res = DAODBOPEN(dbhandle, s, 0, 0, "") 
IF EQ(res, -1)
  ; Error
  PrintErrors(dbhandle)
  ABORT 1
FI
RETURN


FUNCTION OpenTable(dbhandle, rshandle, t)

; Open table t in database; store into rshandle its handle
rshandle = DAORSNEW(dbhandle)
res = DAORSOPEN(rshandle, _DAOCOpenTable, t, 0)
IF EQ(res, -1)
  ; Error
  PrintErrors(dbhandle)
  RETURN 0
FI
RETURN 1


FUNCTION PrintRecord(rshandle)

; Load field names into an array
nfield = DAORSGETFIELDCOUNT(rshandle)
fieldnames = VECNEW(nfield)
FOR x = 1 TO nfield
  v = DAORSGETFIELDINFO(rshandle, x)
  VECSET(fieldnames, x, VECGET(v, 1)) 
  VECFREE(v)
NEXT

; If there are records...
IF NOT(AND(DAORSATTRIB(rshandle, _DAORSATTISBOF), DAORSATTRIB(rshandle, _DAORSATTISEOF)))
  ; ...for each record print the contents of all the fields
  DAORSMOVEFIRST(rshandle)
  WHILE NOT(DAORSATTRIB(rshandle, _DAORSATTISEOF))
    FOR x = 1 TO nfield
      CONSOLELN "  Field: " PADR(VECGET(fieldnames, x), 20, " ") " Value: " DAORSGETFIELDVAL(rshandle, x)
    NEXT
    CONSOLELN ""
    DAORSMOVENEXT(rshandle)
  LOOP
FI
VECFREE(fieldnames)
RETURN


FUNCTION PrintErrors(dbhandle)

; Print all DAO errors resulting from last operation
numerr = DAOERRCOUNT(dbhandle)
FOR x = 1 TO numerr
  CONSOLELN "Error " x ":" 
  CONSOLELN "  Code       : " DAOGETERRORNUM(dbhandle, x)
  CONSOLELN "  Description: " DAOGETERRORDESC(dbhandle, x)
  CONSOLELN "  Source     : " DAOGETERRORSRC(dbhandle, x)
  CONSOLELN ""
NEXT
RETURN
Samples index Next example Previous example Contents Index
Midnight Lake iPhone Case Black Women Shoes Black Flat Shoes Leather Flats Black Patent Ballerinas Black Ballet Shoes Casual Shoes Black Shoes Women Balle Record Player Cufflinks Best iPhone XR Clear Cases iPhone XS/XS Max Leather Cases Sale Best iPhone 8/8 Plus Silicone Cases iPhone 7/7 Plus Cases & Screen Protector New Cases For iPhone 6/6 Plus iPhone 8 Case Sale iPhone Xr Case Online iPhone 7 Case UK Online iPhone X Case UK Sale iPhone X Case Deals iPhone Xs Case New Case For iPhone Xr UK Online Case For iPhone 8 UK Outlet Fashion Silver Cufflinks For Men Best Mens Cufflinks Outlet Online The Gold Cufflinks Shop Online Cheap Shirt Cufflinks On Sale Nice Wedding Cufflinks UK Online Top Black Cufflinks UK Online Mens Cufflinks Online Silver Cufflinks For Men Men Cufflinks UK Sale Gold Cufflinks UK Online Gold Cufflinks UK Silver Cufflinks UK Shirt Cufflinks Discount Online Mens Cufflinks Deals & Sales Girls Shoes For Dance Fashion Ballet Dance Shoes Best Ballet Flats Shoes UK Online Cheap Ballet Pointe Shoes UK Online Best Ballet Shoes Outlet Best Dance Shoes Sale Cheap Ballet Flats Sale UK Best Pointe Shoes Online UK Ballet Dance Shoes UK Shoes For Dance UK Best Ballet Slippers Shop Best Yoga Shoes Hotsell