[fpc-pascal] Get highest element of a StringList

Thomas Kurz fpc.2021 at t-net.ruhr
Sat Sep 10 19:11:37 CEST 2022


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 at lists.freepascal.org>
To: 'FPC-Pascal users discussions' <fpc-pascal at 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 at lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal



More information about the fpc-pascal mailing list