Re: Union followed by Property does not compile !
Skybuck Flying <[email protected]> Fri, 12 Aug 2022 15:43:15 -0700 (PDT)
| Newsgroups | alt.comp.lang.borland-delphi |
|---|---|
| Message-ID | <[email protected]> |
A solution was provided by Michael Van Canneyt on the free pascal compiler mailing list via an e-mail to me: " The variant part of a record must always come last. The property should be moved to before the 'case' : TDataExample2 = record mField : integer; property Field : integer read mField write mField; case integer of 0 : ( mData : int64 ); 1 : ( mByte : packed array[0..7] of byte ); end; This compiles when I tried. Michael. " I, Skybuck, tried this myself, and surprisingly it worked, at least so far: TDataExample2 = record private mField : integer; public // SOLUTION: property Field : integer read mField write mField; // PUT CASE STATEMENT LAST case integer of 0 : ( mData : int64 ); 1 : ( mByte : packed array[0..7] of byte ); end; There are ofcourse other rules that must be followed, if I recall correctly, procedures must come before properties :) Though apperently I am wrong about that too, could have sworn there were some rules about it, so far this seems to work as well: // it actually works... interesting ! ;) TDataExample2 = record private mField : integer; public // SOLUTION: property Field : integer read mField write mField; procedure Test; // PUT CASE STATEMENT LAST case integer of 0 : ( mData : int64 ); 1 : ( mByte : packed array[0..7] of byte ); end; procedure TDataExample2.Test; begin end; Perhaps classes have different rules, not sure. Anyway, it's very hot today, so I keep this investigation short for now ! ;) =D :P* Bye, Skybuck =D