Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 To: Nadeem Shah
  Where is Nadeem Shah?
 Rawalpindi
 Pakistan
 Nadeem Shah
 Tags
Subject: RE: Access & assign methods of new property
Thread ID: 155158 Message ID: 155162 # Views: 3 # Ratings: 0
Version: Visual FoxPro 9 Category: Forms
Date: Wednesday, December 26, 2007 5:27:00 PM         
   


> Hi experts
>
> When we create new property then it has to check values
> Access method and assign method.
>
> What is the function of these two methods?
>
> With regards
>
> Nadeem Iqbal

As their names imply one is fired whenever you access that property and other whenever you attempt to assign a value to that property. These methods allow you:
-Control access/assignment (read/write) of property value. This is their basic functionality, rest are sort of 'tricks' to have a greater control or doing some actions.
-Alter the value as it's read or written. ie:
You may want to provide 'Undefined' when the value is null. Access handles.
Do not allow a value less than 100 when say you're sizing control - for example form.height_assign.
Alter datatype - for example property should be datetime but consumers might set it with values like date(), datetime(), null or character expressions like 'Today','Yesterday','10 PM' etc. Assign method handles the conversion (and access method might do the reverse).
-Broadcasting a message to all controls on a form and ask them to do something. For example your controls that can validate their own data might have a specially named property 'RequiredCheck' and 'RequiredCheck_Assign' might look like (rough pseudo code):

lparameters vNewVal
if m.vNewVal
 if empty(this.Value) or !ValidComparedToAnotherControl() or SomethingElse()
  this.AttachErrorIcon("You need to enter a value blah blah")
  thisform.DataHasError = .t.
 else
   this.DetachErrorIcon()
 endif
endif


and save routine could do:

thisform.SetAll('RequiredCheck', .t.)
if thisform.DataHasError
  * do not continue saving and let user correct
endif


Cetin Basoz

ENTIRE THREAD

Access & assign methods of new property Posted by Nadeem Iqbal @ 12/26/2007 2:49:18 PM
RE: Access & assign methods of new property Posted by Ken Murphy @ 12/26/2007 3:48:13 PM
RE: Access & assign methods of new property Posted by Cetin Basoz @ 12/26/2007 5:27:00 PM
RE: Access & assign methods of new property Posted by Nadeem Iqbal @ 12/28/2007 6:52:45 AM
RE: Access & assign methods of new property Posted by Marcia Akins @ 12/28/2007 5:04:05 PM