Hi Vlad,
I'm afraid, you're proposing quite complicated solution for me. Why do I need forms (with all their overhead), while line object works just fine? Of course, I may consider your idea, when I decide to expand my applications and add forms. Currently I think I'm satisfied with my solution. Do you see problems with it?
>Hi!
>
>I already know that you have working solution, but it seems not quite good.
>
>The work-around idea I just got seems better, with it you will not need to make a separate session object. Make a host form with private data session. Run it outside of screen so users will not see it at all. That form should get parameter - string with command that should be ran under private (separate) data session, or something other (form name). Your call will look like:
>
>Do FORM MySessionHost.SCX WITH "Do MyForm.prg"
>
>or something like that.
>
>In the form you will have method to run other form (if form is modeless), so you will call it:
>
>MySessionHost.DoCommand
>
>For modal forms you can run hosted command just from Init method of host form:
>
>lparameters lpCommand
>&lpCommand
>return .F.
>
>Last 'return .F.' indicates that host form should be released immediately after init finished (modal form finished work).
>
>There might be difficulties, however, when returning some value from modal form, but there are workarounds for that too.
>
>HTH.
>
>>Hi Vlad,
>>
>>First of all, thanks a lot for the quick response.
>>
>> I'd like to distinguish Form's DS from my application DS, IOW, I don't want to overload Form's DS with the tables, which are not relevant to this form. Besides, I may want to open the table, which is used in this form, and do some work on it. That's why I like to keep my application DS separate from calling form DS. That's why I tried the code, I showed, but it didn't work.
>>
>>Therefore, my question is: is it possbile at all to create a separate DS for my application (which currently consists only of programs) or I need to re-organize my application and create class with methods, instead of just programs. I know, this technique works, if there is another object (class) involved (as in my other colleague code this technique works just fine, but he uses classes). I just don't want to complicate my life yet, if it's not absolutely necessary. I was thinking about thisform.lockscreen (though I doubt, it would work).
>>
>>Do you have ideas for me?
>>
>>Thanks in advance.
>>
>>>Hi!
>>>
>>>I never even tried to work with data session by that way because I know a lot of bad things about it. Private data sessions are not reliable in VFP even when used by usual way, what say about manual editing?
>>>
>>>What the goals you want to get to when trying to make data session object manually?
>>>
>>>Note that grids are cleared out probably because original data session for form with grids is gone out of scope somewhere during application running. I think this occurred because data session you made is not native for form.
>>>
>>>> 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):
>>>>>>><<<<
>>>>
>>>>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