use in tmpcur closes tmpcur.
USE always uses a workarea and opens what you specify BEFORE the IN clause of the command and close whatever is in the workarea you specify BY the in clause. So the IN clause specifies where to open something and whatever is open there of course is closed. In can specify a workarea number or alias name. USE IN tmpcur therefore does not address tmpcur.dbf, it addresses the workarea alias tmpcur and it opens NOTHING, as you don't specify anything before the IN keyword, so indeed it means USE
nothing IN
workarea alias name tmpcur.
Any USE something IN 0 works in the next empty workarea (which has this "meta" workarea number 0) and therefore does not close anything, but USE in aliasname is the inverse use of the IN clause, it specifies a certain workarea to CLOSE that aliasname. As a result, you can do a non operation, if you simply write USE IN 0, you specify the empty workarea 0 and nothing to open, so you neither open nor close anything. But the main concept of USE always combines opening and closing, we just very seldom have the case of closing something and opening something else at the same time, but it's possible to eg USE orders in customers, which would open the customers.dbf in the workarea name customers, that workarea in the end will be renamed to orders. I would actually prefer the VFP language to have seperate commands for opening and closing a table, but that's how it is.
If you have something open as alias tmpcur, even the first line will fail:
use dbf('tmpcur') in 0 again alias tmpcur_ exclu
This would mean you open up whatever tmpcur is in another empty workarea (0) again, and you want to open it exclusive. You can't open something exclusive, if it's already open. The only way it may work, if only you have it open exclusive already, but that's not a good excuse for trying that way.
If you have a dbf open shared and want to try to get exclusive access the only thing to do is
Code:
SELECT tmpcur
USE DBF() EXCLUSIVE
This will close whatever is open in the currently selected workarea and reopen it exclusive right away.
Do you work in VFP6? Then similar code is used to reopen query result cursors to be able to write to them. That's needed because VFP6 has no READWRITE clause.
The main recipe here is something like
Code:
* query data:
SELECT ... FROM sometables INTO CURSOR curTmp NOFILTER
* make the result writable:
USE DBF("curTmp") AGAIN IN 0 ALIAS curTmp2
USE IN curTmp
Now you have the result in curTmp2 writable.
There is no need for EXCLUSIVE, DBF("curTMP") will point to your temp folder anyway, and no one else has access there.
Bye, Olaf.