>ndxname = 'X' + SYS(3)
>INDEX ON [fldname] TO &ndxname
>
>Look familiar? This is how we FP'ers have created a new filename since the beginning of time. And I am having a 'File in use by another' error come up on my client's app, sometimes. Actually not sometimes, but always on my client's PC's which run Win98, the error does not happen on the one PC in the store that runs Win95. However, it does not occur on my development PC, which runs Win98 too. It does NOT make sense to me that this is the operative difference but I have nothing else to go on. Any ideas?
Fox itself doesn't guarentee a unique filename with sys(3) (especially on fast computers) and offer sys(2015) instead (on a particular machine different even if called in the same millisecond but of course might be same when called on more then one computers).
Moreover a do while loop could provide one unused :
function GetFreeFileName
lcFileName = "X"+sys(2015)
handle = fcreate(lcFileName)
do while handle < 0
lcFileName = "X"+sys(2015)
handle = fcreate(lcFileName)
enddo
=fclose(handle)
return lcFileName
Also using local path for temporary files would not only prevent collision but improve performance as well.
For indexes instead of new files, using tags would be more effective :
lcTagName = "T"+substr(sys(2015),2)
INDEX ON expression Tag (lcTagName)
delete tag (lcTagName)
Cetin