"The size of the published set '% s' is> 4 bytes." How to fix this compiler error?
I have a set of enumeration values that has 138 values. Sort of:
type
TSomething = (sOne, sTwo, sThree, ..., ..., sOnehundredAndThirtyeight);
TSomethings = set of TSomething;
....
TSomething = class(TPersistent)
private
fSomethings: TSomethings;
published
property Somethings: TSomethings read fSomethings write fSomethings;
end;
When compiling, I get the following error message:
[DCC Error] uProfilesManagement.pas(20): E2187 Size of published set 'Something' is >4 bytes
Any idea on how I can include a set of this size in a published property?
I need to include this set in the published section because I use OmniXMLPersistent to save the class in XML and it only saves the published properties.
Maybe you need the following trick (I am not using OmniXML and cannot verify it):
type
TSomething = (sOne, sTwo, sThree, ..., sOnehundredAndThirtyeight);
TSomethings = set of TSomething;
TSomethingClass = class(TPersistent)
private
fSomethings: TSomethings;
function GetSomethings: string;
procedure SetSomethings(const Value: string);
published
property Somethings: string read GetSomethings write SetSomethings;
end;
{ TSomethingClass }
function TSomethingClass.GetSomethings: string;
var
thing: TSomeThing;
begin
Result:= '';
for thing:= Low(TSomething) to High(TSomething) do begin
if thing in fSomethings then Result:= Result+'1'
else Result:= Result+'0';
end;
end;
procedure TSomethingClass.SetSomethings(const Value: string);
var
I: Integer;
thing: TSomeThing;
begin
fSomethings:= [];
for I:= 0 to length(Value) - 1 do begin
if Value[I+1] = '1' then Include(fSomethings, TSomething(I));
end;
end;