Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Losing Alias When Class Called - Only From One Form
Message
From
10/10/2001 04:46:10
 
 
To
09/10/2001 18:21:41
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00565864
Message ID:
00566310
Views:
10
Hi!

It is dangerous to work with SET DATASESSION command inside of the form. for example, grid might be reconstructed when you do so. I meant:

- Make a class (say, clsDataHandler), put data refreshing and saving methods there. Base it in the Custom VFP class.
- Make a base class for all your forms that work with data. Add clsDataHandler class to the base form class as object.
- In the form code when you work with data, instead of call to public object you call the form object (instead of oApp.Save(), for example, call thisform.oDataHandler.Save()).

HTH.

>>Hi!
>>
>>oApp is a public object, right? Thus it works in the default data session. When you have a form with private data session, all aliases in it are opened in that data session. When you call oApp object from such form, data session is switched by VFP automatically to the data session for that object (oApp) - the data session that was current during that object creating. In your case ther are 2 solutions:
>>
>>1. Put a functionality to the separate object and put that object into your form class, so all forms will have it. then call that functionality in the form. This will assure data session is the same.
>>2. Pass additional parameter to all functions in oApp object that work with data. In the oApp fist lines of code after parameters statement will be code to use SET DATASESSION command to set correct data session.
>>
>>First approach is better.
>>
>>HTH.
>>
>>>I have a oApp class that receives two parameters in order to handle changes to records (save, delete, etc). From one form everything works fine, but from another as soon as the lParameters statement is executed (or at least that is the next line after the call to the class from the form) the Alias is lost. What could cause an Alias to drop given this situation? Thanks!
>>>
>>>Regards, Renoir
>
>Vlad,
>
>I too have had a similar situation, but I fixed it by way of workaround in the load() of a new form - placing a call to setdatasession to... is this what you mean in your first solution? or is there some different way you have in mind?
>TIA
>Ric
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform