Project

General

Profile

TH3-Drop Self » History » Version 1

Wil van Antwerpen, 06/03/2019 01:33 AM

1 1 Wil van Antwerpen
# Drop Self
2 1 Wil van Antwerpen
3 1 Wil van Antwerpen
In recent versions of DataFlex you do not have to use the Self notation when addressing objects.
4 1 Wil van Antwerpen
5 1 Wil van Antwerpen
Eg.
6 1 Wil van Antwerpen
~~~
7 1 Wil van Antwerpen
  Get Value Of (oMyNewForm(Self)) to sValue
8 1 Wil van Antwerpen
~~~
9 1 Wil van Antwerpen
can be written as
10 1 Wil van Antwerpen
~~~
11 1 Wil van Antwerpen
  Get Value Of oMyNewForm to sValue
12 1 Wil van Antwerpen
~~~
13 1 Wil van Antwerpen
14 1 Wil van Antwerpen
The latter form is much easier to read for most human beings, so it is a preferred notation style.
15 1 Wil van Antwerpen
16 1 Wil van Antwerpen
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.
17 1 Wil van Antwerpen
18 1 Wil van Antwerpen
The refactoring method will popup a message box that asks you if you want to change the line of code.
19 1 Wil van Antwerpen
In it's most bare form it does that for each change.
20 1 Wil van Antwerpen
21 1 Wil van Antwerpen
As this is fairly invasive, you can tick a checkbox to remember specific objects.
22 1 Wil van Antwerpen
23 1 Wil van Antwerpen
So if you already decided to rewrite (oMyNewForm(Self)) into oMyNewForm then it remember that particular choice.
24 1 Wil van Antwerpen
25 1 Wil van Antwerpen
You can also keep the current lining out of the code by replacing the "wiped" out part of the code replaced with spaces.
26 1 Wil van Antwerpen
27 1 Wil van Antwerpen
## Why all the questions?
28 1 Wil van Antwerpen
29 1 Wil van Antwerpen
The reason you get the message box is because our parser can not detect everything at this stage.
30 1 Wil van Antwerpen
31 1 Wil van Antwerpen
For example if you are using a property to store a object id then the replacement would break your code.