Author | Topic: How do I say table was created with Fox16 or Fox 32 driver ? | |
---|---|---|
Osvaldo Luis Aoki | How do I say table was created with Fox16 or Fox 32 driver ? on Mon, 31 Oct 2016 17:27:43 +0100 Hi, If I have a created table, how do I say if the format is FOX16 (2X) or FOX32 (Visual Fox) ? Is there any way to say previously ? Thanks Osvaldo | |
Andreas Gehrs-Pahl | Re: How do I say table was created with Fox16 or Fox 32 driver ? on Mon, 31 Oct 2016 19:38:50 -0400 Osvaldo, >If I have a created table, how do I say if the format is FOX16 (2X) or >FOX32 (Visual Fox) ? Is there any way to say previously ? You can check the file header, using low level FOpen()/FRead() functions and check the first byte of the database (header), which determines the format. The DBInfo() function, which would probably be a simpler and better option, has no define constant to report this DBO value. But keep in mind that plain FoxPro 2 database files without a memo file use the same header code value as dBASE III database files, even though they can contain incompatible field types. It is much easier to check if a database is in Visual FoxPro format or not, by testing for the three VFP markers. The following code should get you started: #include "FileIO.ch" #define PLAIN_DBF_FILE chr(0x03) #define VFP_DBF_FILE chr(0x30) #define VFP_AUTO_INC chr(0x31) #define VFP_VARIABLE_LEN chr(0x32) #define FOXPRO_WITH_MEMO chr(0xF5) Function Get_Dbf_Version(cFile) LOCAL cFormat := "DBF" LOCAL cBuffer := Space(1) LOCAL nHandle := FOpen(cFile, FO_READ) if FError() == 0 FRead(nHandle, @cBuffer, 1) FClose(nHandle) else ? "Error opening the file: ", cFile, FError() endif if cBuffer == VFP_DBF_FILE .or. cBuffer == VFP_AUTO_INC .or. ; cBuffer == VFP_VARIABLE_LEN cFormat := "VFP" elseif cBuffer == PLAIN_DBF_FILE .or. cBuffer == FOXPRO_WITH_MEMO cFormat := "FP2" endif return (cFormat) Possible (hex) values for the first byte are: * 02 ==> FoxBASE * 03 ==> dBASE III, FoxPro 2.x, FoxBASE+, FlagShip, etc. (no memo file) * 04 ==> dBASE IV (no memo file) * 05 ==> dBASE V (no memo file) * 07 ==> Visual Objects (no memo file) * 30 ==> Visual FoxPro (with or without DBC, with or without memo file) * 31 ==> Visual FoxPro (with AutoIncrement field) * 32 ==> Visual FoxPro (with VarChar or VarBinary fields) * 43 ==> FlagShip (with DBV (variabl-size) memo file) * 43 ==> dBASE IV (with SQL table files, no memo file) * 63 ==> dBASE IV (with SQL system files, no memo file) * 7B ==> dBASE IV (with dBASE IV-format memo file) * 83 ==> dBASE III, FoxBase, etc. (with DBT memo file) * 87 ==> Visual Objects (with memo file) * 8B ==> dBASE IV (with DBT memo file) * 8E ==> dBASE IV (with SQL table) * B3 ==> FlagShip (with DBV and DBT memo files) * CB ==> dBASE IV (with SQL table files and memo) * E5 ==> Six-Driver (with SMT memo file) * F5 ==> FoxPro 2.x (with FPT memo file) * FB ==> FoxBASE There are several other codes in the DBF header that might help with determining the exact file format more precisely. For some additional info, see: http://www.clicketyclick.dk/databases/xbase/format/index.html or use Google to find additional sites. Hope that helps, Andreas Andreas Gehrs-Pahl Absolute Software, LLC phone: (989) 723-9927 email: Andreas@AbsoluteSoftwareLLC.com web: http://www.AbsoluteSoftwareLLC.com [F]: https://www.facebook.com/AbsoluteSoftwareLLC | |
Osvaldo Luis Aoki | Re: How do I say table was created with Fox16 or Fox 32 driver ? on Wed, 02 Nov 2016 23:37:20 +0100 HI Andreas, Very good function. Thanks! Osvaldo Andreas Gehrs-Pahl wrote in message news:shlfiz3rxom1.1x8omsy4oc68d.dlg@40tude.net... >Osvaldo, > >>If I have a created table, how do I say if the format is FOX16 (2X) or >>FOX32 (Visual Fox) ? Is there any way to say previously ? > >You can check the file header, using low level FOpen()/FRead() functions and >check the first byte of the database (header), which determines the format. >The DBInfo() function, which would probably be a simpler and better option, >has no define constant to report this DBO value. > >But keep in mind that plain FoxPro 2 database files without a memo file use >the same header code value as dBASE III database files, even though they can >contain incompatible field types. It is much easier to check if a database >is in Visual FoxPro format or not, by testing for the three VFP markers. > >The following code should get you started: > >#include "FileIO.ch" > >#define PLAIN_DBF_FILE chr(0x03) >#define VFP_DBF_FILE chr(0x30) >#define VFP_AUTO_INC chr(0x31) >#define VFP_VARIABLE_LEN chr(0x32) >#define FOXPRO_WITH_MEMO chr(0xF5) > >Function Get_Dbf_Version(cFile) >LOCAL cFormat := "DBF" >LOCAL cBuffer := Space(1) >LOCAL nHandle := FOpen(cFile, FO_READ) > if FError() == 0 > FRead(nHandle, @cBuffer, 1) > FClose(nHandle) > else > ? "Error opening the file: ", cFile, FError() > endif > > if cBuffer == VFP_DBF_FILE .or. cBuffer == VFP_AUTO_INC .or. ; > cBuffer == VFP_VARIABLE_LEN > cFormat := "VFP" > elseif cBuffer == PLAIN_DBF_FILE .or. cBuffer == FOXPRO_WITH_MEMO > cFormat := "FP2" > endif >return (cFormat) > >Possible (hex) values for the first byte are: >* 02 ==> FoxBASE >* 03 ==> dBASE III, FoxPro 2.x, FoxBASE+, FlagShip, etc. (no memo file) >* 04 ==> dBASE IV (no memo file) >* 05 ==> dBASE V (no memo file) >* 07 ==> Visual Objects (no memo file) >* 30 ==> Visual FoxPro (with or without DBC, with or without memo file) >* 31 ==> Visual FoxPro (with AutoIncrement field) >* 32 ==> Visual FoxPro (with VarChar or VarBinary fields) >* 43 ==> FlagShip (with DBV (variabl-size) memo file) >* 43 ==> dBASE IV (with SQL table files, no memo file) >* 63 ==> dBASE IV (with SQL system files, no memo file) >* 7B ==> dBASE IV (with dBASE IV-format memo file) >* 83 ==> dBASE III, FoxBase, etc. (with DBT memo file) >* 87 ==> Visual Objects (with memo file) >* 8B ==> dBASE IV (with DBT memo file) >* 8E ==> dBASE IV (with SQL table) >* B3 ==> FlagShip (with DBV and DBT memo files) >* CB ==> dBASE IV (with SQL table files and memo) >* E5 ==> Six-Driver (with SMT memo file) >* F5 ==> FoxPro 2.x (with FPT memo file) >* FB ==> FoxBASE > >There are several other codes in the DBF header that might help with >determining the exact file format more precisely. For some additional info, >see: http://www.clicketyclick.dk/databases/xbase/format/index.html or use >Google to find additional sites. > >Hope that helps, > >Andreas |