Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Weird private datasession behaviour
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Titre:
Weird private datasession behaviour
Divers
Thread ID:
00625511
Message ID:
00625511
Vues:
40
If you cut out the following code and paste it into sessionbug.prg and then "DO SESSIONBUG WITH 1" and follow instructions you will see a VFP bug in action. Can someone confirm this and suggest a workaround ?

PROCEDURE SessionBug
LPARAMETERS vnFoxSession

IF EMPTY(vnFoxSession)
= MESSAGEBOX("You must pass a numeric parameter", 16, "Session Bug")
RETURN .f.
ELSE
IF VARTYPE(vnFoxSession) != "N"
= MESSAGEBOX("You must pass a numeric parameter", 16, "Session Bug")
RETURN .f.
ELSE
IF vnFoxSession > 3
= MESSAGEBOX("You must pass either 1 or 3", 16, "Session Bug")
RETURN .f.
ENDIF
ENDIF
ENDIF

SET EXCLUSIVE OFF

IF INLIST(vnFoxSession, 1, 3)
IF NOT FILE("TestTable.DBF")
CREATE TABLE TestTable FREE (;
TestField C(60))
USE
ENDIF

loForm1 = CREATEOBJECT("frmForm_1")
loForm1.Show()

= MESSAGEBOX("We have added a record to the test table. " + ;
"You should now start another session of fox and type '" + ;
"DO sessionbug WITH 2' in the command window. " + ;
"Press the OK button here when instructed by the " + ;
"program in the new session of fox.", 16, "Session Bug")

IF vnFoxSession = 1
= MESSAGEBOX("This next screen will now display the value of the data " + ;
"stored in the table.", 16, "Session Bug")
ELSE
= MESSAGEBOX("This next screen will be a browse window of the table and then " + ;
"the form to now display the value of the data " + ;
"stored in the table.", 16, "Session Bug")
SELECT 0
USE TestTable
BROWSE NORM
USE
ENDIF

loForm3 = CREATEOBJECT("frmForm_3")
loForm3.Show()

IF vnFoxSession = 3
= MESSAGEBOX("What does the value say? This form will be displaying " + ;
"the correct value rather than the old value. Simply because" + ;
"we have browsed the table.", 16, "Session Bug")

SET REFRESH TO 1,1 && so that browse window updates correctly
ELSE
= MESSAGEBOX("What does the value say? This form will be displaying " + ;
"the old value (which is wrong) rather than the new changed value. " + ;
"we will now close the first form and redisplay this form.", 16, "Session Bug")

loForm1.Release()
loForm3.Release()

loForm3 = CREATEOBJECT("frmForm_3")
loForm3.Show()

= MESSAGEBOX("What does the value say? This form should now be displaying " + ;
"the correct value... why is it so? To see how it probably should work " + ;
"run this program again with a parameter of 3", 16, "Session Bug")
ENDIF
ELSE
IF NOT FILE("TestTable.DBF")
= MESSAGEBOX("You must run this program with a 1 parameter first.", 16, "Session Bug")
RETURN .f.
ENDIF

loForm2 = CREATEOBJECT("frmForm_2")
loForm2.Show()

= MESSAGEBOX("We have now changed this value so you need to swap back to the first " + ;
"session of fox you started and press the OK button on the message box.", 16, "Session Bug")
ENDIF
ENDPROC

DEFINE CLASS cfrmTestForm AS Form
DataSession = 2
ADD OBJECT text1 AS textbox
text1.readonly = .t.
text1.top = 10
text1.width = 200
ENDDEFINE

DEFINE CLASS frmForm_1 AS cfrmTestForm
top = 10
left = 10

FUNCTION Init()
SET MULTILOCKS ON
SELECT 0
USE TestTable
= CURSORSETPROP("Buffering", 5)

INSERT INTO TestTable (;
TestField) ;
VALUES ("Description " + ALLTRIM(STR(RECCOUNT(),10,0)))

= TABLEUPDATE(1, .f.)

thisform.text1.value = testtable.testfield
ENDFUNC
ENDDEFINE

DEFINE CLASS frmForm_2 AS cfrmTestForm
top = 10
left = 10

FUNCTION Init()
SET MULTILOCKS ON
SELECT 0
USE TestTable
= CURSORSETPROP("Buffering", 5)

GO BOTT
REPLACE testfield WITH "Changed " + ALLTRIM(testfield)

= TABLEUPDATE(1, .f.)

thisform.text1.value = testtable.testfield
ENDFUNC
ENDDEFINE

DEFINE CLASS frmForm_3 AS cfrmTestForm
top = 200
left = 200
FUNCTION Init()
SELECT 0
USE TestTable
GO BOTT
thisform.text1.value = testtable.testfield
ENDFUNC
ENDDEFINE
Cheers,
Jamie
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform