Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Fun with _Access and _Assign
Message
De
11/01/2008 02:24:25
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Titre:
Fun with _Access and _Assign
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Divers
Thread ID:
01281068
Message ID:
01281068
Vues:
61
Hi All,

something nice for you to track:

If you use _ASSIGN and _ACCESS Methods for the WIDTH and Height properties, the methods have side effects.
The use of the Width_Access calls the Width_Assign by its own. It also calls Visible_Access twice for no visible reason - but only if the object is visible!

I've checked this with VFP7,8,9 SP2

Use the code below to trace.
CLEAR
_SCREEN.ADDOBJECT('ix','mytext')
_SCREEN.ix.VISIBLE= .T.
SET STEP ON
=_SCREEN.ix.WIDTH
?_SCREEN.ix.gncount
_SCREEN.ix.gncount=0
_SCREEN.ix.VISIBLE= .f.
=_SCREEN.ix.WIDTH
?_SCREEN.ix.gncount
_SCREEN.REMOVEOBJECT('Ix')

DEFINE CLASS mytext AS TEXTBOX
 HEIGHT = 23
 WIDTH = 100
 NAME = "mytext"
 gncount = 0


 PROCEDURE width_access
  RETURN THIS.WIDTH
 ENDPROC


 PROCEDURE width_assign
  LPARAMETERS vNewVal
  THIS.WIDTH = m.vNewVal
 ENDPROC


 PROCEDURE visible_access
  THIS.gncount = THIS.gncount + 1
  RETURN THIS.VISIBLE
 ENDPROC


 PROCEDURE visible_assign
  LPARAMETERS vNewVal
  THIS.VISIBLE = m.vNewVal
 ENDPROC
ENDDEFINE
*
*-- EndDefine: mytext
**************************************************
Update:
Don't need help, can you just test it?
2nd Update:
try with Top and Left to

Replace the = on line 4 with ? and see how the result of line 5 changes. (VFP 7 only)
Check with and without debugger.
Agnes
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform