CreateIndex does not erase temporary files
Posted: Wed Feb 13, 2019 8:07 pm
I have the following problem when using CreateIndex to create temporary indexes:
Since the temporary index file is not erased at the end of the process, I forced it by adding the following code to erase it manually:
Isn't FW supposed to erase the temporary index file by itself?
Emiliano Llano Díaz
Code: Select all
//1st function
USE Clients Alias clients SHARED NEW
DATABASE oDbfC
//temporary index CreateIndex( [cFile], cTag, cKey, [lUnique], [lDescend], [lMemory] )
oDbfC:CreateIndex( nil, "Clients", "Client->Name" , nil, nil, .T.)
oDbfH:LOAD()
oDbfH:GoTop()
BrowseTable( oDbfC )
oDbfC:CLOSE()
// 2nd function:
SELECT animals
DATABASE oDbfG
//create temporary index CreateIndex( [cFile], cTag, cKey, [lUnique], [lDescend], [lMemory] )
oDbfG:CreateIndex( nil,"Main", "animals->number" , nil, nil,.T.) //error here since tmp.cdx exist
oDbfG:CreateIndex( nil,"Name", "Left(PADR(ALLTRIM(animals->Name),25),25)" , nil, nil,.T.)
oDbfG:CreateIndex( nil,"Color", "Left(PADR(ALLTRIM(animals->Color),25),25)" , nil, nil,.T.)
oDbfG:CreateIndex( nil,"Brand", "Left(PADR(ALLTRIM(animals->Brand),3),3)" , nil, nil,.T.)
oDbfG:CreateIndex( nil,"Born", "DTOS(animals->Born)" , nil, nil,.T.)
oDbfG:CreateIndex( nil,"BornNum", "DTOS(animals->Born) + animals->number" , nil, nil,.T.)
...
Code: Select all
//1st function
USE Clients Alias clients SHARED NEW
DATABASE oDbfC
//temporary index CreateIndex( [cFile], cTag, cKey, [lUnique], [lDescend], [lMemory] )
if File( GetcurDir()+"\tmp.cdx" ) //should have been done by Fivewin since this is a temp index
FErase( GetcurDir()+"\tmp.cdx" )
endif
oDbfC:CreateIndex( nil, "Clients", "Client->Name" , nil, nil, .T.)
oDbfH:LOAD()
oDbfH:GoTop()
BrowseTable( oDbfC )
oDbfC:CLOSE()
oDbfC:End() //this was added to see if the temporary index file was erased (did not work)
// 2nd program:
SELECT animals
DATABASE oDbfG
//create temporary index CreateIndex( [cFile], cTag, cKey, [lUnique], [lDescend], [lMemory] )
if File( GetcurDir()+"\tmp.cdx" )
FErase( GetcurDir()+"\tmp.cdx" )
endif
oDbfG:CreateIndex( nil,"Main", "animals->number" , nil, nil,.T.) //No error since I erased tmp.cdx
oDbfG:CreateIndex( nil,"Name", "Left(PADR(ALLTRIM(animals->Name),25),25)" , nil, nil,.T.)
oDbfG:CreateIndex( nil,"Color", "Left(PADR(ALLTRIM(animals->Color),25),25)" , nil, nil,.T.)
oDbfG:CreateIndex( nil,"Brand", "Left(PADR(ALLTRIM(animals->Brand),3),3)" , nil, nil,.T.)
oDbfG:CreateIndex( nil,"Born", "DTOS(animals->Born)" , nil, nil,.T.)
oDbfG:CreateIndex( nil,"BornNum", "DTOS(animals->Born) + animals->number" , nil, nil,.T.)
...
Emiliano Llano Díaz