<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Howard Page-Clark via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>> schrieb am Mo., 3. Feb. 2020, 11:22:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">FPC 3.0.4 compiles this code excerpt without a murmur:<br>
<br>
== code ==<br>
<br>
{$mode objfpc}{$H+}<br>
<br>
type<br>
<br>
TSheetInfo = record<br>
name: String;<br>
tab: String;<br>
title: String;<br>
kind: TSheetKind; // an enumeration<br>
color: TColor;<br>
end;<br>
<br>
TBaseSheet = class(TTabSheet)<br>
protected<br>
FSheetInfo: TSheetInfo;<br>
...<br>
public<br>
constructor Create(aComponent: TComponent; aSheetInfo: TSheetInfo); <br>
virtual; reintroduce;<br>
...<br>
property SheetKind: TSheetKind read FSheetInfo.kind; // <<<br>
end;<br>
<br>
TEntryGrid = class(TCustomStringGrid)<br>
private<br>
FParentSheet: TBaseSheet;<br>
...<br>
public<br>
constructor Create(AOwner: TComponent; aParentSheet: TBaseSheet); <br>
reintroduce;<br>
...<br>
property SheetKind: TSheetKind read FParentSheet.FSheetInfo.kind; // <<<br>
end;<br>
<br>
== code end ==<br>
<br>
However, more recent FPCs (and trunk) reject this at the properties <br>
(marked above <<) with the error "Record or object type expected".<br>
<br>
Is there a modeswitch or other wheeze that will get recent FPCs to <br>
accept dotted notation when specifying property read and write fields?<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">This is simply not allowed for class fields. That it was, was essentially a bug ( <a href="https://wiki.freepascal.org/User_Changes_Trunk#Property_field_access_lists_no_longer_allows_classes">https://wiki.freepascal.org/User_Changes_Trunk#Property_field_access_lists_no_longer_allows_classes</a> ). </div><div dir="auto">Either use records or (TP style) objects or use a getter. If you declare it as "inline" you can essentially get the same code (with the added bonus that you can raise an exception should the field be Nil). </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>