Project

General

Profile

TH3-Drop Self » History » Version 2

Wil van Antwerpen, 06/03/2019 01:37 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 2 Wil van Antwerpen
7 1 Wil van Antwerpen
~~~
8 2 Wil van Antwerpen
Get Value Of (oMyNewForm(Self)) to sValue
9 1 Wil van Antwerpen
~~~
10 1 Wil van Antwerpen
can be written as
11 2 Wil van Antwerpen
12 1 Wil van Antwerpen
~~~
13 2 Wil van Antwerpen
Get Value Of oMyNewForm to sValue
14 1 Wil van Antwerpen
~~~
15 1 Wil van Antwerpen
16 1 Wil van Antwerpen
The latter form is much easier to read for most human beings, so it is a preferred notation style.
17 1 Wil van Antwerpen
18 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.
19 1 Wil van Antwerpen
20 1 Wil van Antwerpen
The refactoring method will popup a message box that asks you if you want to change the line of code.
21 1 Wil van Antwerpen
In it's most bare form it does that for each change.
22 1 Wil van Antwerpen
23 1 Wil van Antwerpen
As this is fairly invasive, you can tick a checkbox to remember specific objects.
24 1 Wil van Antwerpen
25 1 Wil van Antwerpen
So if you already decided to rewrite (oMyNewForm(Self)) into oMyNewForm then it remember that particular choice.
26 1 Wil van Antwerpen
27 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.
28 1 Wil van Antwerpen
29 1 Wil van Antwerpen
## Why all the questions?
30 1 Wil van Antwerpen
31 1 Wil van Antwerpen
The reason you get the message box is because our parser can not detect everything at this stage.
32 1 Wil van Antwerpen
33 1 Wil van Antwerpen
For example if you are using a property to store a object id then the replacement would break your code.