Hi Pete Salyer,
1. If you are using a form, the best way will be to use a form level property.. Assume you are using two temp files.. create a form level property.. cTemp1 and cTemp2.
Then in the init event of the form.. put the code..
ThisForm.cTemp1 = SYS(3)
ThisForm.cTemp2 = SYS(3)
Beware the SYS(3) function is very tricky. In very fast machines, it used to give duplicate values. To avoid that, I always tend to add a small catcher code like this ...
DO WHILE ThisForm.cTemp1 = ThisForm.cTemp2
ThisForm.cTemp2 = SYS(3)
ENDDO
Now you can use this cTemp1 or cTemp2 at appropriate places
with reference to ThisForm.cTemp1 etc.
Then to delete the temp files, in the forms DESTROY EVENT put the code...
CLOSE ALL
IF !EMPTY(ThisForm.cTemp1)
DELETE FILE (ThisForm.cTemp1)+".DBF"
DELETE FILE (ThisForm.cTemp1)+".FPT"
DELETE FILE (ThisForm.cTemp1)+".CDX"
DELETE FILE (ThisForm.cTemp1)+".IDX"
ENDIF
IF !EMPTY(ThisForm.cTemp2)
DELETE FILE (ThisForm.cTemp2)+".DBF"
DELETE FILE (ThisForm.cTemp2)+".FPT"
DELETE FILE (ThisForm.cTemp2)+".CDX"
DELETE FILE (ThisForm.cTemp2)+".IDX"
ENDIF
And repeat it as many time as the cTemp1/2/3/4 etc is craeted. Note (1) that even if the file is not existing, the above code will not create any error. Note (2) that when the SQL SELECT is creating to DBF cTemp1, the file gets initialised by SQL and so all the records get zaped to start with.
2. If you are using codes to do the job, then you can initialise the cTemp1, cTemp2 etc in the beginning of the PRG file for this instance
PRIVATE cTemp1, cTemp2
cTemp1 = SYS(3)
cTemp2 = SYS(3)
DO WHILE cTemp2 = cTemp1
cTemp2 = SYS(3)
ENDDO
and then do rest.
When the prg is RETURNing to called routine when the close tables are issued, follow it up the code...
IF !EMPTY(cTemp1)
DELETE FILE cTemp1+".DBF"
DELETE FILE cTemp1+".FPT"
DELETE FILE cTemp1+".CDX"
DELETE FILE cTemp1+".IDX"
ENDIF
IF !EMPTY(cTemp2)
DELETE FILE cTemp2+".DBF"
DELETE FILE cTemp2+".FPT"
DELETE FILE cTemp2+".CDX"
DELETE FILE cTemp2+".IDX"
ENDIF
This will work perfectly. I have used this type of coding in my applications. Hope this helps you.
ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK
