Using a case
Statement with String Selectors
|
procedure TakeAction (MyString : string);
begin
with TStringList.Create do
try
CommaText:= 'String1,String2,..., StringN';
case IndexOf(MyString) of
0 : DoString1Action;
1 : DoString2Action;
...
N : DoStringNAction;
else DoSomethingElse;
end;
finally
Free;
end;
end; |
|
Notes:
This code shares the case-insensitive properties of the IndexOf
function.
If a CommaText sub-string includes spaces or commas, it must be enclosed in double-quotes, as in
|
|
CommaText:= 'String1,"S t r i n g
2",...,StringN'; |
|