Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Factory Objects - practical application
Message
From
18/12/2006 12:30:04
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
17/12/2006 18:40:10
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01177742
Message ID:
01178606
Views:
29
Hi Olaf

>You might cause problems when changing the session of a form or of objects belonging to a form (added by AddObject), but changing goApp's session will not cause any trouble. In that respect all works as for the session class, when code runs in a class it works in it's active session. That's why instead of a session ID parameter of some methods a general setDatasession() method is also a good way to set the session and then run any method in that session, eg.
>
>
>goApp.setDatasession(set("datasession"))
>goApp.oData.getSomeData()...
>goApp.resetDatasession()
>
>

I find it a much better practice to instantiate an object which remembers the data session. This object resets the data session upon release or the end of the method.
*Some method
LOCAL loSetDataSession
SET CLASSLIB TO somevcx.vcx
loSetDataSession = CreateObject("cusPushPopSetTo","DATASESSION")

*Do some thing
RETURN && data session is reset at this point.
However, doing that code exactly like that means I cannot subclass the cusPushPopSetTo nor rearrange my classlibs.

I'm hoping to do this:
LOCAL m.loSetDataSession
m.loSetDataSession = ;
  oFactory.New(SET("DATASESSION"),;
  "alias for cusPushPopSetTo class",;
  "DATASESSION")<pre>

I could use a udf to avoid passing the current datasession, but there's not much point to that, but it would be something like this (not tested).

<pre>NewObjectX.prg
lparameters m.tcClassAlias,m.tuParm1,...m.tuParm23
LOCAL lcParms
lcParms = x5pitems("m.tuParm1,...m.tuParm23",PCOUNT())
Return EVALUATE([oFactory.New(SET("DATASESSION"),m.tcClassAlias,] + m.lcParms +[)]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform