Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Datasessions
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00723973
Message ID:
00723980
Views:
21
This message has been marked as the solution to the initial question of the thread.
>Hi,
>
>what is the simpliest way to get all open datasessions id's?
>
>Is there a native function?
>
>Thanks

Not sure about native function (tried to find it in VFP8 help, but failed). Here is a function we have:
************************************************************
*  Author............: Douglas N. Gray (GRAYbase)
*  Created...........: 10/11/2001
*  Description.......: Creates a public array of all existing datasessions.
*  Calling Samples...: =ADATASESSIONLIST("laDS")
*  Parameter List....: tcArrayname
*  Returns...........: Max number of existing datasessions.
************************************************************
PARAMETER tcarrayname
IF VARTYPE(tcarrayname)#"C"
	=MESSAGEBOX('Missing or Invalid array name',16,'ADATASESSIONLIST Program')
	RETURN 0
ENDIF
IF VARTYPE(&tcarrayname) # "U"
	SET STEP ON
	=MESSAGEBOX('The passed name of '+tcarrayname+', is already in use.'+CHR(13)+CHR(10)+;
		'This method is terminating prematurely.',16,'ADATASESSIONLIST Program')
	RETURN 0
ENDIF

PUBLIC ARRAY &tcarrayname(1)
LOCAL lcOldError
lcOldError=ON('error')						&& Store current ON ERROR setting
ON ERROR llValidSession = .F. 				&& Supress Error mesages
LOCAL i,llValidSession,lnTableCount,lnDSCount
lnDSCount=0
FOR i = 1 TO 20
	llValidSession = .T.
	lnTableCount = AUSED(laAlias,i) && If DS doesn't exist, this line throw an 1540 error
	IF llValidSession AND m.lnTableCount>0	&& Valid datasession & has tables open in it.
		lnDSCount = lnDSCount+1				&& Increment counter.
		DIMENSION &tcarrayname(lnDSCount)	&& Redimension Array.
		&tcarrayname.[lndscount] = i		&& Add the datasession id to the array.
	ENDIF
NEXT

*--- Kill public array if none found.
IF lnDSCount =0
	RELEASE &tcarrayname
ENDIF

ON ERROR &lcOldError						&& Reset ON ERROR setting.

RETURN lnDSCount
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform