Another alternative would be declaring a helper:

type TStringListHelper = class helper for TStringList
function High: NativeInt;
end;

function TStringListHelper.High: NativeInt;
begin
  Exit (Self.Count-1);
end;


----- Original Message ----- 
From: James Richters via fpc-pascal <fpc-pascal@lists.freepascal.org>
To: 'FPC-Pascal users discussions' <fpc-pascal@lists.freepascal.org>
Sent: Saturday, September 10, 2022, 18:01:20
Subject: [fpc-pascal] Get highest element of a StringList

I thought I would try:

For Loop := 0 to High(MyStringList) do

But I get "Error: Type mismatch"

Is there a way to get the highest element of a stringlist other than:

For Loop := 0 to MyStringList.Count-1 do

It would be nice to not have the -1
Could High() be made to work if the argument was a stringlist?

James

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to