Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Set order / private datasession
Message
From
15/11/2001 12:48:31
Charlie Schreiner
Myers and Stauffer Consulting
Topeka, Kansas, United States
 
 
To
14/11/2001 11:00:19
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00581452
Message ID:
00582228
Views:
23
Hi Hilmar,
Just to make it interesting and because I hear no dissenting voices...
It seems to me that your design is flawed any time you resort to SET DATASESSION TO. Each object is responsible to know and control what goes on within it. Messages are passed to objects and the objects respond. Here I would want to send a message to the active form and tell it to reorder itself, whatever that means in the specific form's case. A toolbar button can be generic in that it knows how to send the message to any form. But when it assumes it knows how to change the datasession and set order to and refresh, etc.--well, that's quite a bit of responsiblity for a button that has incomplete knowledge of all possible forms.
I recognize that some of the VFP foundation classes work this way, but I think the code is misplaced. Make a common interface for your forms. Talk to them through that interface. Don't sneak around behind the form's back to muck around with its innards. (obviously using language here with negative connotation)

http://home.kscable.com/cschreiner/OutFoxed16.html

Of course, you make have extenuating circumstances, but as a general goal, why not try to use object.method() to do work in/on an object?

As to the reliablility of SET DATASESSION TO, it just depends. If the toolbar was created in the default datasession, and you have a combobox control or grid in the default datasession, your SET DATASESSION TO isn't very good. A refresh during the time you've changed the DataSessionID will be bad for that control. You can't control the internal VFP refresh, IFAIK. If you don't have those type of controls in a default datasession, you should be fine.

>>Otherwise you can pass Form's DS as a parameter. My colleagues use SET DATASESSION to lnPassedDS lots of times in a code without problems...
>
>Thanks, Nadya and Çetin, for your assurance.
>
>The reason I needed this is because the framework I use remembers current set("order"), but my users sometimes want to see data in the order it was input. Helps them finding data, apparently.
>
>I have created a generic function to do this for the current form. This function included the following commands:
>
>
>loForm = _vfp.ActiveForm
>...
>lnDataSession = set("datasession")
>set datasession to loForm.DataSessionId
>set order to
>set datasession to lnDataSession
>
>
>Plus other, framework-specific, commands, and validity checks.
>
>Hilmar.
Charlie
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform