Sets

Top  Previous  Next

SmartMS supports a limited version of sets. Only sets of enumerations are supported. Only in operator is supported. 

Compiler supports Include and Exclude methods, which can be used in two ways, either as Include(mySet,  value) 

or as mySet.Include(value). 

 

Sets is a datatype of boolean enum values. A set can have all it's states included, unlike a normal enum which can only represent one state. Under Object-Pascal sets have a limit of 255 elements, and are defined as such:

 

Example code:

 type

TMySet = set of (msFirst,msSecond,msThird);

 

// populate set with two states

var FMySet: TMySet;

FMySet:=[msFirst,msThird];

 

 

The Smart Pascal syntax lack support for sets, which is a drawback compared to Delphi and FreePascal. However, sets can be emulated using arrays and constants which incidentally bypass the 255 elements limit.

 

 Set of enumerations with Records in SmartMS

 

 Using Set with Constants 1

 

 Using Set with Constants 2

 

 Using Set of enum