Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Foxpro Problem - By Design
Message
De
18/10/1999 18:10:00
 
 
À
18/10/1999 16:07:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00277692
Message ID:
00277914
Vues:
30
So, explain this to me real slow. Why do you want to create an object and put it in _SCREEN? If you really need this capability, just create a dummy form that you never show, and put your object there. That way you can switch datasessions to your hearts content. Or am I just missing the point?!?



>Using a session class still doesn't work. Any other ideas?
>
>Thanks
>
>>Try using a Session class instead of a Custom class.
>>
>>
>>>No, this doesn't work. Let me explain the problem. If any code that was originally called from a _SCREEN method contains a SET DATASESSION TO command, that command will not work. It doesn't raise an error, it just doesn't work. Here are the steps to reproduce the problem.
>>>
>>>
>>>1. Create a program that contains the following code:
>>>
>>>
>>> CLEAR ALL
>>> PUBLIC yy,Y,zz
>>>
>>> * The target session we are trying to SET TO:
>>> Y = CREATEOBJECT("zform")
>>>
>>> * A separate custom object, which can set to that session:
>>> zz = CREATEOBJECT("myobj")
>>>
>>> * A form in another session, which can set to that session:
>>> yy = CREATEOBJECT("zform2")
>>>
>>> * A member of screen, which will show the problem:
>>> _SCREEN.ADDOBJECT("z","myobj")
>>>
>>> Y.SHOW()
>>> yy.SHOW()
>>>
>>> RETURN
>>>
>>> DEFINE CLASS myobj AS CUSTOM
>>>
>>> PROCEDURE SetToActiveSession
>>> WAIT WINDOW TIMEOUT 1 ;
>>> "current ;
>>> session: "+STR(SET("datasession"))
>>> SET DATASESSION TO ;
>>> (_SCREEN.ACTIVEFORM.DATASESSIONID)
>>> WAIT WINDOW "session we want: "+;
>>> ALLTR(STR(_SCREEN.ACTIVEFORM.DATASESSIONID))+ ;
>>> ", "+ CHR(13)+ ;
>>> "session we got: "+ ;
>>> ALLTR(STR(SET("DATASESSION"))) TIMEOUT 3
>>> ENDPROC
>>>
>>> ENDDEFINE
>>>
>>> DEFINE CLASS zform AS FORM
>>> DATASESSION = 2
>>> ENDDEFINE
>>>
>>> DEFINE CLASS zform2 AS zform
>>> AUTOCENTER = .T.
>>> ADD OBJECT z AS COMMANDBUTTON WITH ;
>>> CAPTION="Push Me"
>>> PROCEDURE z.CLICK
>>> WAIT WINDOW TIMEOUT 1 "current session: "+STR(SET("datasession"))
>>> SET DATASESSION TO (Y.DATASESSIONID)
>>> WAIT WINDOW "session we want: "+ ;
>>> ALLTR(STR(Y.DATASESSIONID))+ ;
>>> ", "+CHR(13)+ ;
>>> "session we got: "+ ;
>>> ALLTR(STR(SET("DATASESSION"))) TIMEOUT 1
>>> ENDPROC
>>> ENDDEFINE
>>>
>>>2. Run the program and press the command button. Notice the data session
>>> starts out with a value of three (3) and changes to a value of two (2).
>>>
>>>3. Change the data session from the Command window by typing the following
>>> command:
>>>
>>> zz.SetToActiveSession()
>>>
>>> Notice the data session starts with a value of one (1) and successfully
>>> changes to two (2).
>>>
>>>4. Attempt to change the data session from the Command window using a
>>> method of the _SCREEN object by typing the following:
>>>
>>> _Screen.z.SetToActiveSession()
>>>
>>> Calling the _SCREEN object does not allow you to change the data session
>>> to a value of two (2). It remains a value of one (1).
>>>
>>>Any other ideas?
>>>
>>>Thanks
>>>
>>>
>>>>Try this little trick:
>>>>
>>>>lnDataSession = SET("DATASESSION")
>>>>SET DATASESSION TO x
>>>>
>>>>&&Put whatever code here
>>>>
>>>>SET DATASESSION TO (lnDataSession)
>>>>
>>>>
>>>>
>>>>>While debugging some software, I noticed a strange behavior. My datasessions refused to change when I issued "set datasession to x". So, I looked in the MS Knowledge Base. Article number Q191316 states that this behavior is "by design". I beg everyone to take a look at this article. Other than not calling the method from the _SCREEN object, can anyone think of a work around? Any help would be appreciated.
>>>>>
>>>>>Thanks
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform