Why would the compiler generate a `"E2018 Record, object or class type required" helper` when I use a ToUpperInvariant (or any TStringsHelper call) on the `Text` property of a `TEdit`?
Why would the compiler generate a `"E2018 Record, object or class type required" helper` when I use a ToUpperInvariant (or any TStringsHelper call) on the `Text` property of a `TEdit`?
Full failing code is at https://gist.github.com/jpluimers/b5e3684f725216622bdcb80bf5f10698
Failing line is this:
```
Edit1.Text := Edit1.Text.ToUpperInvariant;
// the above line generates this error:
// [dcc32 Error] MainFormUnit.pas(29): E2018 Record, object or class type required
```
This fails as well:
```
Edit1.Text := TStringHelper.ToUpperInvariant(Edit1.Text);
```
Why would the compiler (in this case XE8) throw this error?
Note the workaround is simple:
```
var
lText: string;
begin
lText := Edit1.Text;
Edit1.Text := lText.ToUpperInvariant;
```
My suspicion is that the `Edit` property is of type `TCaption` which is `type string`.
Could it be that simple?
Full failing code is at https://gist.github.com/jpluimers/b5e3684f725216622bdcb80bf5f10698
Failing line is this:
```
Edit1.Text := Edit1.Text.ToUpperInvariant;
// the above line generates this error:
// [dcc32 Error] MainFormUnit.pas(29): E2018 Record, object or class type required
```
This fails as well:
```
Edit1.Text := TStringHelper.ToUpperInvariant(Edit1.Text);
```
Why would the compiler (in this case XE8) throw this error?
Note the workaround is simple:
```
var
lText: string;
begin
lText := Edit1.Text;
Edit1.Text := lText.ToUpperInvariant;
```
My suspicion is that the `Edit` property is of type `TCaption` which is `type string`.
Could it be that simple?
Yup, the issue is TCaption has no helper. Pretty distressing.
ReplyDeleteAttila Kovacs So that it can be identified as a distinct type and get special treatment by the designer.
ReplyDeletehttps://stackoverflow.com/a/8825493/505088
stackoverflow.com - Delphi Type equivalence and Type equality syntax