Set Of String??!!
Sets are implemented using bit arrays. So no, you cannot have a 'set of string'. Use a TStringList instead, ie:
var
mySet: TStringList;
S: String;
begin
S := ...;
mySet := TStringList.Create;
try
mySet.Add('a');
mySet.Add('b');
mySet.Add('c');
if mySet.IndexOf(S) <> -1 Then ShowMessage('Exists');
finally
mySet.Free;
end;
end;
You can make use of this.
type
TAnyEnum = (aeVal1, aeVal2, aeVal3);
TEnuns = set of TAnyEnum;
TAnyMessages: array [TAnyEnum] of String;
const
MyMessages: TAnyMessages = ('Exists', 'Something else', 'WTF!?');
var
MySet : TEnums;
begin
MySet = [aeVal1, aeVal2];
If aeVal1 in MySet then ShowMessage(MyMessages[aeVal1]);
end;
The RTL System.StrUtils
unit provides a very interesting method for this:
function MatchText(const AText: string; const AValues: array of string): Boolean; overload;
Use it like this:
if MatchText(sLanguages, ['fr-FR', 'en-GB', 'de-DE', 'it-IT', 'fr-CH', 'es-ES']) then
Writeln('found')