// DIRDBF( <cSpec> [, <cDbf> ][, <cNtx> ][, <cDrvr> ] ) -> <nErrcode>
TEST( "*.dbf","dbffiles","filename" )
// ----------------------------------------
FUNCTION Test( spec, dbf, ntx,drvr )
LOCAL ret_val := DIRDBF( spec,dbf,ntx,drvr )
IF ret_val > 0
IF ret_val == 1
MsgAlert("File Spec. Not Passed", "Error")
ENDIF
IF ret_val == 2
MsgAlert("No Files Match Passed Spec.", "Error" )
ENDIF
IF ret_val == 3
MsgAlert("Network Problem Creating " + upper(dbf) + ".DBF", "Error", "Error")
ENDIF
ELSE
USE "DBFFILES.dbf"
XBROWSE()
ENDIF
RETURN NIL
// ---------------------------------
FUNCTION DIRDBF( spec, dfile, ntx, driver )
LOCAL adbf, struc, orig_area, error_code := 0
FIELD name
IF spec==NIL; error_code:= 1
ELSE
dfile := IF( dfile==NIL,"files",dfile )
adbf := { {"Name","C",12,0},;
{"Size","N",9,0}, ;
{"Date","D",8,0}, ;
{"Time","C",8,0}, ;
{"Attr","C",4,0} }
IF EMPTY( struc:= DIRECTORY(spec) ); error_code:= 2
ELSE
orig_area:= SELECT()
DBCREATE(dfile,adbf)
USE (dfile) EXCLUSIVE NEW VIA (driver)
IF NETERR(); error_code:= 3
ELSE
Aeval( struc, {|e,n| dbAppend(), ;
Fieldput(F_NAME,struc[n][F_NAME]),;
Fieldput(F_SIZE,struc[n][F_SIZE]),;
Fieldput(F_DATE,struc[n][F_DATE]),;
Fieldput(F_TIME,struc[n][F_TIME]),;
Fieldput(F_ATTR,struc[n][F_ATTR]) } )
IF ntx <> NIL; INDEX ON name TO (ntx); END
CLOSE (dfile)
SELECT(orig_area)
ENDIF
ENDIF
ENDIF
RETURN ( error_code )
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 80 guests