Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BindEvents bug
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
BindEvents bug
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows 2000 SP4
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
00973564
Message ID:
00973564
Vues:
57
I get different results when running the following program under VFP 8 and 9.

The program uses the combination of a global accessor and BINDEVENT to create an object proxying system where one object can stand in for another.

Under VFP 8 and the VFP 9 Beta, the program executes correctly. I get the expected result of the instance of the Imposter class posing as RealObject.

Under the release version of VFP 9, the code breaks. The BINDEVENT function is disregarding the delegate return value and using the Event return value instead.
LOCAL loImposter, loRealObject

loImposter = CREATEOBJECT("Imposter")
loRealObject = CREATEOBJECT("RealObject")

loImposter.PoseAs(loRealObject)

?loImposter.Name
?loImposter.Class
?loImposter.HelloWorld()

RETURN

DEFINE CLASS Imposter AS CUSTOM

  PROCEDURE Self
    RETURN THIS
  ENDPROC

  PROCEDURE PoseAs
    LPARAMETERS toClient
    *-- If you use an nFlags value of 1, the value returned by a 
    *-- method call to the event is not that of the event, 
    *-- but rather that of the last delegate invoked.
    BINDEVENT(THIS, "self", toClient, "self", 1)
  ENDPROC
  
  PROCEDURE THIS_ACCESS
    LPARAMETERS tcPEMName
    LOCAL loHandler
    IF tcPEMName == "self" OR tcPEMName == "poseas"
      loHandler = THIS
    ELSE
      loHandler = THIS.Self()
    ENDIF
    RETURN loHandler
  ENDPROC

ENDDEFINE

DEFINE CLASS RealObject AS CUSTOM

  PROCEDURE Self
    RETURN THIS
  ENDPROC

  PROCEDURE HelloWorld
    RETURN "Hello World!"
  ENDPROC

ENDDEFINE
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform