Drop Self¶
In recent versions of DataFlex you do not have to use the Self notation when addressing objects.
Eg.
Get Value Of (oMyNewForm(Self)) to sValue
can be written as
Get Value Of oMyNewForm to sValue
The latter form is much easier to read for most human beings, so it is a preferred notation style.
The refactoring option "Drop Self" helps you to find and rewrite all the object notations that use the legacy self style and suggests to change them into the variant without Self. Hence the name.
The refactoring method will popup a message box that asks you if you want to change the line of code.
In it's most bare form it does that for each change.
As this is fairly invasive, you can tick a checkbox to remember specific objects.
So if you already decided to rewrite (oMyNewForm(Self)) into oMyNewForm then it remember that particular choice.
You can also keep the current lining out of the code by replacing the "wiped" out part of the code replaced with spaces.
Why all the questions?¶
The reason you get the message box is because our parser can not detect everything at this stage.
For example if you use a property to reference an object then the Self notation is required.
Here's a code example of when you cannot remove the Self.
Object oTest is a cObject Property Handle phoTestObject Set phoTestObject to Self Procedure Hello Showln "Hello" End_Procedure Send Hello of (phoTestObject(Self)) End_Object
When you change the Send Hello line into:
Send Hello of phoTestObject
Your code no longer compiles.