Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find available datasessions?

Status
Not open for further replies.

wgcs

Programmer
Mar 31, 2002
2,056
EC
Especially during a failure in the ON ERROR routine, I'd like to be able to see what files are open in every datasession...

This would be easy to do using AUSED(arr, DS_ID), except that there is no way that I can figure out how to determine which DS_ID's would be valid to check.

Since AUSED throws an error (which can't be trapped with ON ERROR if you are inside an object that has an Error method) when the DS_ID doesn't exist, I can't just try DS_ID 1 thru 10.

So, how do you determine (in VFP6) what DS's are used?
 
HI

DSID exist only for Private DS forms. So to get the id, you should first check if
IF Object.DataSession = 2
myDSID = Object.DataSessionID
ENDIF

For the default data session, DSID doesnt exist.
:)
ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
What I'm looking to do is enhance my anomoly reporting function so that it doesn't only report on the current datasession, but also reports what is open in every other datasession.

For example, one of my program's functions failed with a "File in Use" error. It was running on a client's machine, and so all I had to go by was my errorlog, which lists all the files open in the current datasession (among other things), but that file wasn't open. I think I've found how it could have been left open in a datasession from a different form, but if I could have the errorlog list all files in all datasessions, it would be much easier.

In a simplistic way, what I want is:
Code:
LOCAL laUsed[1]
STRTOFILE( "Current DataSession="+SET("DATASESSION")+chr(13), "ERRORLOG.TXT" )
FOR lnI= 1 to HighestUsedDatasession()
  IF DataSessionExists(lnI)
    SET DATASESSION TO (lnI)
    LIST STATUS TO Errorlog.txt ADDITIVE
  ENDIF
  * OR *
  IF DataSessionExists(lnI)
    lnCnt = AUSED( laUsed, lnI )
    STRTOFILE( tran(lnCnt)+" files used in DS "+tran(lnI)+chr(13), "ERRORLOG.TXT", .t. )
    for lnJ = 1 to lnCnt
      STRTOFILE( "  "+laUsed[lnJ]+chr(13), "ERRORLOG.TXT", .t. )
    endif
  ENDIF
ENDFOR

I can't find anything to tell what these two functions would:
HighestUsedDatasession()
DataSessionExists(lnI)

We rarely have more than a couple of Forms open at a time, so I could just use 20 instead of HighestUsedDatasession(), but without the function DataSessionExists(lnI) I can't protect the SET DATASESSION TO or the AUSED() functions, which throw an error if the DS doesn't exist.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top