Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Access Method
Message
 
 
To
19/12/2019 11:28:32
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Miscellaneous
Thread ID:
01672305
Message ID:
01672349
Views:
74
Something I still need to clarify in your example (it is me :)).
Do I understand that your code would work only when you define the class (e.g. cmdSmartButton) in code?
How would you change it if the class is created visually?
That is, how would you set the following code in a visual class?
DEFINE CLASS cmdSmartButton AS CommandButton 
  ForeColor  = oDef.defcolor && Change button text color ONCE via a method
ENDDEFINE
Thank you.

>Link is in my reply to Tore. Add a few more buttons, switch on runs between basing on Smart or Dumb button and just watch the count of wait windows....
>
>>Thank you very much.
>>
>>>Sounds somewhat familiar
>>>It is markedly faster via _access IF YOU ONLY SET IN THE COMMON BASECLASSES, not in every instance of the class.
>>>Speed benefit of making sneaking _access between property read and normal function/method exists, but is seldom worth it (about half the time needed for _access vs. function call).
>>>The boost comes from NOT calling function or _access 50 or more times when property is once set on first instantiation of a class depending on that particular base class. Run the code in my example for Dragan...
>>>
>>>>>>>>>>Hi,
>>>>>>>>>>
>>>>>>>>>>I looked at the VFP 9 help but the explanation of Access method is not easily understood. Could someone explain the purpose, the use, and advantages of using the Access Method (e.g. something_Access).
>>>>>>>>>>
>>>>>>>>>>TIA
>>>>>>>>>
>>>>>>>>>Tamar explains it well in this article: http://www.tomorrowssolutionsllc.com/Articles/Put%20Access%20methods%20to%20work.pdf
>>>>>>>>>And this is one of Doug's articles: http://doughennig.com/Papers/Pub/AccessAssign.pdf
>>>>>>>>
>>>>>>>>Thank you, Tore.
>>>>>>>
>>>>>>>You're welcome.
>>>>>>>
>>>>>>>Just to give you one sample. I use business classes for all my tables. For each field I have access methods, which all are something like this:
>>>>>>>
>>>>>>>*Myfield_access
>>>>>>>Return Evaluate(Myfield)
>>>>>>>
>>>>>>>So when I want to read this field value, I simply call MyClass.MyField.
>>>>>>>
>>>>>>>Likewise, I have an "opposite" method Myfield_assign which I use to change the field value.
>>>>>>
>>>>>>Your example is much easier to read than many pages of an article. Thank you.
>>>>>>I have to follow with a very newbie question.
>>>>>>How is your Myfield_access different from assigning the value of the field to a property and getting the value from a property directly?
>>>>>
>>>>>The property Myfield in a way is this property you mention. It hides all the logic necessary to read and write to the table.
>>>>>
>>>>>Another sample is a business class for contact information. You have a property for first name, middle name, last name and full name. The three first have access methods to read the corresponding field values from the contact info table, using Evaluate(). The property FullName contains no value, instead it contains this code:
>>>>>
>>>>>*FullName_access
>>>>>lcReturn = Alltrim(This.firstname) + ' '
>>>>>If !Empty(This.middlename
>>>>>   m.lcReturn = m.lcReturn + Alltrim(This.middlename) + ' '
>>>>>Endif
>>>>>m.lcReturn = m.lcReturn + Alltrim(This.lastname)
>>>>>Return m.lcReturn
>>>>>
>>>>>One last comment: I really encourage you to read the two documents, assign and access methods can make your life so much easier.
>>>>
>>>>I was writing a reply to your message (actually a question) but someone called and I lost my message.
>>>>Here is my question.
>>>>My understanding is that Access "hides" the implementation but does not really make the execution any faster (correct me if I am wrong).
>>>>The reason I am checking this method is if it applies to the following situation:
>>>>My application has a global object (oApp). I want to add a property to this global object, oApp.text_forecolor and set the value of this property (at the top of the application). E.g.
>>>>
>>>>oApp.text_forecolor = "0,0,255"
>>>>
>>>>
>>>>Then every text box of the application, when being instantiated, will set the forecolor to this value. Example:
>>>>
>>>>*-- Some textbox
>>>>INIT Method
>>>>this.forecolor = oApp.text_forecolor
>>>>
>>>>
>>>>Would it make more sense (for the speed) to use the Access method instead of the INIT method to set the textbox ForeColor?
>>>>
>>>>Thank you.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform