Stewart's idea works good as long as your definition of "cursor" includes Tables, Views and Cursors. If you only want true Cursors, then you'll probably need to use the DBF() function to verify the table name. Note also that AUSED() allows an optional datasession parameter, so if you have multiple data sessions, you'll need to check them all.
If you don't think they are supposed to be there,
then something is wrong. But the names seem appropriate.
Darrell
BTW
Here's a basis to get all open table/cursor/views open
in all datasessions in VFP.
Obviously it would exhaust VFP's array limits if
there are too many tables open.
[tt]
CLEAR MEMO
* Open a lot of tables in mulitple
* datasessions
LOCAL ARRAY aDS[1]
DIME aDS[100]
FOR i = 1 TO 100
aDS[ i ] = CREATEOBJECT("clsDS"
NEXT
* This array will contain all
* of the open table names with
* the datasessions they are open in
* aOpenTables[x,1]<-TableName
* aOpenTables[x,1]<-DataSession
LOCAL ARRAY aOpenTables[1,2]
LOCAL nOpenTables
nOpenTables = GetOpenTables(@aOpenTables)
SUSP
FUNCTION GetOpenTables(aArrayIn)
LOCAL nOpenTables && Return value
LOCAL cErrHand && Current error handler
LOCAL nError && Used by local error trap
LOCAL ARRAY aTables[1] && Holds tables open in datasessions
LOCAL nTables && Table count in datasessions
LOCAL i, j
LOCAL nNextTable
DIME aArrayIn[1]
nOpenTables = 0 && Set return value
nNextTable = 0
cErrHand = ON("error" && Save error handler
ON ERROR nError = ERROR() && And set a new one
nError = 0 && Set initial error value
FOR i = 1 TO 32000
nTables = AUSED(aTables,i)
IF nTables > 0
IF nError<>0
EXIT
ENDIF
nNextTable = IIF(nOpenTables>0,nOpenTables,0)
nOpenTables = nOpenTables + nTables
DIME aArrayIn[nOpenTables,2]
FOR j = 1 TO nTables
aArrayIn[nNextTable+j,1] = aTables[j,1]
aArrayIn[nNextTable+j,2] = aTables[j,2] && or i
NEXT
ENDIF
NEXT
ON ERROR &cErrHand && Reset error handler
RETURN nOpenTables
ENDFUNC
DEFINE CLASS clsDS AS SESSION
DATASESSION = 2
PROCEDURE INIT
LOCAL ARRAY aTbls2Open[1], aTblNames[1]
LOCAL nTable2Open, i
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.