Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Object and datasessions (again)
Message
 
To
21/07/1999 16:10:59
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00244270
Message ID:
00245860
Views:
11
>Hi, Stephen
>Do you know why ?

Yes, the object resides in the data session that was current when the object ws created. This does not eman that you cannot cahnge the data session for an object. The SET DATASESSION TO command is exactly for this purpose.

For example, a global Customer (public is a dirty word) object is created in the default (command window's) data session. It has a method to get the next customer record for a form that requests that service. The met+hod might be written like this;
* Get next customer
LPARAMETERS piDataSession
* accept the data session id from the calling form
LOCAL liDataSession, lcAlias

* Save the current data session id
liDataSession = SET("Datasession")

* Change to the data session of the requesting form
SET DATASESSION TO &piDataSession

* Save the currently selected work area in the form's session
lcAlias = ALIAS()

* Select the work area you and do what you need to do
SELECT Customer
SKIP

* Restore the work area in the form's data session
IF NOT EMPTY(lcAlias)
   SELECT (lcAlias)
ELSE
   SELECT 0
ENDIF

* Restore the data session for this object
SET DATASESSION TO &liDatasession

* get out of here
RETURN
Previous
Reply
Map
View

Click here to load this message in the networking platform