Sven Jauring wrote:
type INT0_255 = packed 0..255;
BITS = (BIT0,BIT1,BIT2,BIT3, BIT4,BIT5,BIT6,BIT7, BIT8,BIT9,BIT10,BIT11, BIT12,BIT13,BIT14,BIT15);
var VARIABLE1 : record case int16 of 0: (WORD: INTEGER); 1: (MSB: INT0_255; LSB: INT0_255); 2: (BT : set of BITS); end;
In order for this declaration to function properly, I seem to need the possibility to specify 'BT' to be just 16 bits, and not 32 bits, which seems to be default.
Unfortunately you are probably right, according to the following small program (.. with a maximum of packed)
program test;
type INT0_255 = packed 0..255;
BITS = (BIT0,BIT1,BIT2,BIT3, BIT4,BIT5,BIT6,BIT7, BIT8,BIT9,BIT10,BIT11, BIT12,BIT13,BIT14,BIT15);
INT16 = integer(16); CARD16 = cardinal(16);
var r32 : packed record case int16 of 0: (WORD:cardinal); 1: (WORD1,WORD2: CARD16); 2: (LSB1,MSB1,LSB2,MSB2: INT0_255); 3: (BT1,BT2 : packed set of BITS); end;
b : bits;
begin writeln(SizeOf(r32)); with r32 do begin WORD:=$DEADBEEF; writeln(word2,' ',word1); writeln(msb2,' ',lsb2,' ',msb1,' ',lsb1); for b:=bit15 downto bit0 do if b in bt2 then write('1') else write('0'); for b:=bit15 downto bit0 do if b in bt1 then write('1') else write('0'); writeln; end; end. Size is 8 bytes, bt2 is all zero, out of aligment with the remaining.
Maurice