ÿ@SUBJECT:RE: HOW TO KNOW IF IT'S A DBF N
Hi JTENDERS !
This is what you asked :
//------------------------------------------------------------------------
// --- Written by PHILL TERRY ---
FUNCTION IsDBF( File2Check )
LOCAL ItsADBF := .F.
LOCAL nChkHdl := 0
LOCAL cChkBfr := " "
LOCAL cChkLEN := 1
LOCAL nByteRead := 0
nChkHdl := FOPEN( File2Check )
nByteRead := FREAD( nChkHdl, @cChkBfr, cChkLEN )
FCLOSE( nChkHdl )
IF CHR(03) $ cChkBfr .OR.;
CHR(131) $ cChkBfr
ItsADBF := .T.
ENDIF
RETURN ItsADBF
//-------------------------------------------------------------------------
To check only the FIRST byte of the file. This is only valid for
Clipper-made .DBF files, too. That first byte's value could vary for
database files produces by other programs. The "96" that was included
as "a byte to check" was actually the "year of last update".
Here is a portion of text that I snagged off CI$ that describes a .DBF's
header structure (again, this is specific to Clipper-produced .DBF
files)...
Table: File description record
------------------------------------------------------------------
Offset Format Contents
------------------------------------------------------------------
0 03 or 083h Signature Byte:
03h - (.dbf) with no memo (.dbt) file
083h- (.dbf) with memo (.dbt) file
1 Year Last update year without century
2 01 to 12 Month of last update
3 01 to 31 Day of last update
4-7 Long Number of records
8-9 Word Location in file where data begins
(START)
10-11 Word Record length (field sizes plus 1)
12-31 N/A Reserved
------------------------------------------------------------------
... given this, perhaps checking bytes 2-4 (offset 1-3) would be an
idea .. you could see if the date was "reasonable".
--- FidoPCB v1.5 beta-'e'
---------------
* Origin: Innovatron, St-Boniface, QC (819)535-9072 (1:167/420)
|