Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Open DBF with missing FPT
Message
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01070532
Message ID:
01070561
Vues:
18
John,

You can remove FPT flag in the header of the table using LLFF. Here's a sample code.
CLOSE DATA
lcTableName = "H:\tmp\temp.dbf"

CREATE TABLE (lcTableName) ( c1 C(10), m2 M)
INSERT INTO (lcTableName) VALUES ( "A", "A")
INSERT INTO (lcTableName) VALUES ( "B", "B")
INSERT INTO (lcTableName) VALUES ( "C", "C")
INDEX ON c1 TAG c1
USE
ERASE( FORCEEXT(lcTableName, "FPT")

* You've to pass the full table name including extension 
? RemoveFptFlag (lcTableName)

RETURN 
*-------------------------------

FUNCTION RemoveFptFlag 
LPARAMETERS tcTableFullName
LOCAL lcBuffer, lcRetVal, lnFptFlag

* 0x02 - table has a Memo field 
lnFptFlag = 0x02

* Open table low-level as a text file
lnFh1 = FOPEN(tcTableFullName,12)
IF lnFh1 < 0
  lcRetVal = "***CANNOT OPEN TABLE***"
  RETURN lcRetVal 
ENDIF

* Position of the flags byte
= FSEEK(lnFh1, 28, 0)
lcBuffer = FREAD(lnFh1, 1)
IF BITAND(ASC(lcBuffer), lnFptFlag) = 0
  * table doesn't have FPT file
  lcRetVal = "***Table doesn't have FPT file***"
  RETURN lcRetVal 
ENDIF

***? ASC(lcBuffer)

= FSEEK(lnFh1, 28, 0)
FWRITE(lnFh1, CHR(BITAND(ASC(lcBuffer), BITXOR(0xFF, lnFptFlag))))

**** Check new value
***= FSEEK(lnFh1, 28, 0)
***lcBuffer = FREAD(lnFh1, 1)
***? ASC(lcBuffer)

= FCLOSE(lnFh1)
lcRetVal = ""
RETURN lcRetVal
>We have an application that uses free tables and there is a memo file for one of our critical tables. The question came up, what do we do if the memo file becomes corrupt or separated from the corresponding DBF. When you try to select this file within our application, you get the typical "memo file is missing or invalid". Is there a way to remove the link between the FPT memo file and DBF? The data in the memo file is important, just not nearly as important as the DBF, and of course, we can't rely on the client to backup their data regularly, so we want to at LEAST be able to recover the data in the DBF even if we lose the data in the memo file.
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform