Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Rename a custom property of my class?
Message
From
26/03/2009 10:46:34
 
 
To
26/03/2009 10:08:57
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01391579
Message ID:
01391602
Views:
42
This is really important to me, since I have several poorly named custom properties in my form base class, which are set in each of the SCX instances. I really would like to convert them to the Hungarian naming convention.

Plus it just seems like a good tool to have floating around the community for refactoring.

How about this idea: iterate over all the SCX forms in a project file and handle the rename like this (some pseudo code included below):
Procedure RenameProperty

Lparameters tcProjectFile, tcOldPropertyName, tcNewPropertyName

Use (tcProjectFile)

scan over each SCX file
 llRenameReturn=FixPropertyName(tcOldPropertyName, tcNewPropertyName)  && See your method in previous post
 if llRenameReturn=.t.
   llDeleteReturn=DeleteProperty(OldPropertyName) && Don't know how to do this
 endif
endscan


So it would be a two-step process:

1. Manually rename the property in the base class
2. Do RenameProperty('MyProjtect.pjx', 'stupid_old_name', 'cBetterName')






>Matt --
>
>The result is as you fear, I believe.
>
>When you rename the property in your base form class and then go revisit a form based on that class, you'll see that that property (with the new name) shows up as default -- not the value that you had set it to.
>
>And, curiously, if you then go back to the base form class and change the name back -- presto, the values you set in the sub-class re-appear!  (Not that it does you any good).
>
>If this is really important, you can do the following:
>
>(1)  Instead of re-naming your property in your base class, just create the new property.
>
>(2)  Then, copy the old property value to the new one, as follows (invoke this for each form)
><pre>Modify Form (oFile.Name) Nowait
>FixPropertyName()
>Activate Window 'Form'
>Keyboard '{CTRL+w}'
>DoEvents
>
>Procedure FixPropertyName
>     Local laObjects(1), loForm
>     ASelObj(laAobjects,1)
>     loForm = laAobjects(1)
>     loForm.(newpropertyname) = loForm.(oldpropertyname)
>endproc
>
>(3) Delete your old property.
>
>This might be more work than is worth it. On the other hand, it's a nice technique to have
>
>
>
>>Is there any way I can rename a property on my base form class so that it will not break all the forms based on that class that have overridden that property?
>>
>>I have a custom property named "form_title" that I wish I had named "cFormTitle", but every SCX form already has that property set to a value, and if I rename the property in my base class, won't that break the SCX file, as far as losing the value of that property?
>>
>>I know I can use the Code Refences to address the use of that property name in method code, but what about the issue of the property name/ value that I have set on each form SCX?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform