Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
New DS in a program - have problems - Urgent!
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
New DS in a program - have problems - Urgent!
Miscellaneous
Thread ID:
00458554
Message ID:
00458554
Views:
46
Hi everybody,

We have a main application, called JobControl, which in turn calls other applications. I have my application, called Stats. This application currently consists of several programs, which perform different statistics calculation. They worked in Form's DS. Today I decided, that it would be better to distinguish JobControl Form's DS from Stats DS, so I added the following in Stats main program: (commented this code for now):
*!*		do CREATEPRIVATEDATASESSION with "oStatsData" && Distinguish Data Sessions
*!*		set datasession to oStatsData.datasessionid
	llReturn=RunConfig(funcid_arg, cmdrob_arg, infile_arg, outfil_arg, param1, param2, param3) && for now
*!*		set datasession to oStatsData.pPriorDataSession && Restore back
*!*		release oStatsData
	if not empty(lcAlias)
	   select (lcAlias)
	   goto lnRecno
	endif   
	if vartype(oJC)='O'
	  oJC.CurAppStat=iif(llReturn,'C','I')
	endif  
	return
This is CreatePrivateDS procedure code:
*  Description.......: Creates a private datasession and an object by which you can control it.
*  Calling Samples...: DO CREATEPRIVATEDATASESSION WITH "oReportData"
*					 : Use "RELEASE object name to close (i.e. RELEASE oReportData).
*  Parameter List....: tcclassname = Name of datasession object created.
*  Returns...........: Nothing
*  How to use		 : After creating the object (passed parameter).  Change your datasession to the one ;
*					 : created by typing SET DATASESSION TO oReportData.datasessionid.
*					 : Then open any tables you need and process.
*					 : When your done, you need to move back to your previous work area like:
*					 : "SET DATASESSION TO oReportData.ppriordatasession".  Then release the object ;
*					 : "RELEASE oReportData
*					 :
*  Properties		 : ppriordatasession = Holds the datasession id of the datasession you were in ;
*					 : at the time of creating the object.
************************************************************
procedure CREATEPRIVATEDATASESSION
parameter tcClassName

*--- Check if already exists.
if type(tcClassName)="O"
	return
endif

public &tcClassName

&tcClassName = createobject('privatedata',set('DATASESSION'))

define class privatedata as session
	ppriordatasession = set('DATASESSION')

	procedure init
	parameter tnpriordatasession

*--- scoped to data session...
	set deleted on
	set century on
	set talk off
	set multilocks on
	set exact on
	set ansi on
	set near off
* --
	this.ppriordatasession = tnpriordatasession
endproc


*!*		PROCEDURE setdatasession
*!*			PARAMETER tndatasession
*!*			This.ppriordatasession = SET('DATASESSION')		&& Save current datasession.
*!*			SET DATASESSION TO tndatasession				&& Change datasessions
*!*		ENDPROC

enddefine
When I finish with my app and return to JobControl Form, all grids appear empty. What can I do, to prevent this behavior? Is it valid to create a new DS in a program or it would work only for class?
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform