Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I prevent a class from changing datasession?
Message
From
08/06/2002 14:39:30
 
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00666267
Message ID:
00666325
Views:
19
>>I created a custom class, and sub-classed it for each table in my database.
>>I createobject() in dbc_AfterOpenTable(cTableName). I put all my data validation routines into it, but sometimes when one of the methods starts, it switches datasessions and can't find the table. I think I reached the conclusion that it switches to whatever datasession it was created in. And whenever I try to use it from a different datasession, it crashes.
>>
>>TIA
>
>That's the way classes work, they inherit the datasession they're created in. If you need your class to work in a specific datasession, create that class in that datasession, or pass the datasessionid to your class as a parameter. Just be sure to set it back to whatever it was before you return from your class.

Hi Fred,

I kinda figured that out the hard way.
But do I HAVE to set it back to whatever it was before returning? Wouldn't the class that I was in before automatically set it back?
public goC1
goC1 = createObject('c1')                      && datasession 1

do form whatever                               && datasession 2
  whatever.method()
    goC1.SomeThing(set('DataSession'))
    .....                     <<<<<<<<<<< would datasession AUTOMATICALLY change back to 2 here?
  endmethod
endform

define class c1 as custom      
  procedure SomeThing(nDataSession)
    set datasession to nDataSession
    ..... 
  endproc
enddefine
Bill Morris
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform