Normalt kan man ikke bruge String i en case-sætning, men her er en funktion der tillader det:
function StringToCaseSelect
(Selector : string;
CaseList: array of string): Integer;
var cnt: integer;
begin
Result:=-1;
for cnt:=0 to Length(CaseList)-1 do
begin
if CompareText(Selector, CaseList[cnt]) = 0 then
begin
Result:=cnt;
Break;
end;
end;
end;
{
Usage:
case StringToCaseSelect('Delphi',
['About','Borland','Delphi']) of
0:ShowMessage('You''ve picked About') ;
1:ShowMessage('You''ve picked Borland') ;
2:ShowMessage('You''ve picked Delphi') ;
end;
MvH
Stefan Svensson
http://www.remote-unlock.dk