[fpc-pascal] Get highest element of a StringList

Martin Wynne martin at 85a.uk
Mon Sep 12 19:30:34 CEST 2022


On 12/09/2022 15:37, James Richters via fpc-pascal wrote:
> So.... I could just do this?
> 
> Index:= MyStringlist.IndexOfName(SearchName);
> If Index >=0 then
>     MyValue := MyStringlist[Index].ValueFromIndex;
> 

Hi James,

I would probably do

try
   with MyStringList do MyValue:=ValueFromIndex[IndexOfName(SearchName)];
except
   MyValue:='';
end;

cheers,

Martin.


More information about the fpc-pascal mailing list