I want do something like this:
Result = 'MyString' in [string1, string2, string3, string4];
This can’t be used with strings and I don’t want to do something like this:
Result = (('MyString' = string1) or ('MyString' = string2));
Also I think that creating a StringList to do just this is too complex.
Is there some other way to achieve this?
Thanks.
You could use
AnsiIndexText(const AnsiString AText, const array of string AValues):integerorMatchStr(const AText: string; const AValues: array of string): Boolean;(Both fromStrUtilsunit)Something like:
or
Note
AnsiIndexTexthas case-insensitively andMatchStris case sensitive so I guess it depends on your useEDIT: 2011-09-3: Just found this answer and thought I would add a note that, in Delphi 2010 there is also a
MatchTextfunction which is the same asMatchStrbut case insenstive. — Larry