does anybody encounter a Limit on the number of items on Enumerated sets? I cannot put more than 32 items

does anybody encounter a Limit on the number of items on Enumerated sets? I cannot put more than 32 items

Edit:
Sample Code

type
  TTablesDef = (tbl1,tbl2,...,tbl33,tbl34);
  TTableSet = set of TTablesDef;

  TSomeClass = class(TSomeClassAlso)
  private
    FTables : TTableSet;
  public
   procedure SomeMethod(someparam:dword) ;
   constructor Create(someparam) : override;
    destructor Destroy;
  end;
  
procedure TSomeClass.SomeMethod(someparam:dword);
begin
  FTables := TTableSet(someparam);
end;

Comments

  1. sets can have not more than 255 elements. 32 - is limit of RTTI.
    type
      TByteSet = set of 0..255;
    var
      TMySetVar: TByteSet; // compile
    type
      TComp =class(TComponent)
      private
        FF: TByteset;
        procedure SetF(const Value: TByteset);
      published
        property F: TByteset read FF write SetF; // doesnt compile, because type Tbyteset does not have RTTI.
      end;

    ReplyDelete
  2. Thanks for the replies, Any workaround?

    ReplyDelete
  3. Use a different data structure. You didn't post any code or mention what your using the set for. Perhaps it's not the most appropriate structure for the type of data you're working on.

    ReplyDelete
  4. Jemer Garibay Workaround:  Don't use RTTI for sets.  :-)

    I have a bunch of utility functions that can do bitwise modifications of 255-bit enumerated sets, load/store them as Hex, Etc.  They will also work on smaller enumerated sets - the compiler scales sets to fit the number of defined enumerated flags. 

    You are welcome to the source code if you like.

    I use encrypted enumerated sets to manage end-user privileges in my apps.

    ReplyDelete

Post a Comment