Following code creates and zaps a dbf with an NTX index and then adds some new records. When skipping through the records, they appear twice, showing that the index is corrupted. Output:
TEST4
TEST5
TEST6
TEST4
TEST5
TEST6
Problem happens with DBFNTX only, DBFCDX works well.
FUNCTION Start() AS VOID
LOCAL cDbf AS STRING
RddSetDefault("DBFNTX")
// RddSetDefault("DBFCDX") // works ok with DBFCDX
cDbf := "C:\Dbf\TestZap"
FErase(cDbf + ".DBF")
FErase(cDbf + ".NTX")
FErase(cDbf + ".CDX")
DbCreate(cDbf, {{"LANDLORD","C",10,0}})
DbUseArea(TRUE,, cDbf)
DbCreateIndex( cDbf,"LANDLORD" )
DbAppend()
FieldPut(1,"TEST1")
DbAppend()
FieldPut(1,"TEST2")
DbAppend()
FieldPut(1,"TEST3")
// same if dbf is reopened
/*DbCloseArea()
DbUseArea(TRUE,, cDbf)
DbSetIndex( cDbf,"LANDLORD" )*/
DbZap()
DbAppend()
FieldPut(1,"TEST4")
DbAppend()
FieldPut(1,"TEST5")
DbAppend()
FieldPut(1,"TEST6")
DbCommit()
// same if dbf is reopened
/*DbCloseArea()
DbUseArea(TRUE,, cDbf)
DbSetIndex( cDbf,"LANDLORD" )*/
DbGoTop()
? RecCount() // 3, correct
DbGoTop()
DO WHILE !Eof()
? FieldGet(1)
DbSkip()
ENDDO
?
DbCloseArea()
Following code creates and zaps a dbf with an NTX index and then adds some new records. When skipping through the records, they appear twice, showing that the index is corrupted. Output:
Problem happens with DBFNTX only, DBFCDX works well.