Forum > LCL

[soled] StringList.CustomSort - how to migrate from Delphi?

(1/5) > >>

Nicole:
For the person, who knows the answer, it should be very easy.
I used in Delphi StringList.CustomSort and see in Lazarus StringList.CustomSort "wrong number of parameters".
For me it looks the same, - what do I have to change?
Thanks!

Below is the call and the function. Both works in Delph (and as the parameter are different, I do not understand why by myself. It is really old code):


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- SL_SUB.CustomSort(StringListSortComparefn2);


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TFrame_Korrelationen.StringListSortComparefn2(List: TStringList; Index1, Index2: Integer): Integer;var  i: Integer;     s:string;     d1, d2: double;     gueltig: Boolean; begin // in List werden die gegeneinander zu sortierenden Zeilen übergeben   result:=0;  d1:=0; d2:=0;  If (List[Index1] = '') or (List[Index2] = '') then exit;   i:=0;   s:=List[Index1];  i:=AnsiPos(':',s);  // 'AD Korrelation zu BO: -15,3%'  if (i < 1) then exit; // bei Null wird es nicht gefunden  s:=copy(s, i+1,Length(s));  s:=Trim(s);  s:=copy(s, 0, Length(s) -1);  Trim(s);  gueltig:=TryStrToFloat(s,d1);  if gueltig=false then exit; // absichtlich keine Fehlermeldung, können zuviele werden!  d1:=Abs(d1);   s:=List[Index2];  i:=AnsiPos(':',s);  // 'AD Korrelation zu BO: -15,3%'  if (i < 1) then exit; // bei Null wird es nicht gefunden  s:=copy(s, i+1,Length(s));  s:=Trim(s);  s:=copy(s, 0, Length(s) -1);  Trim(s);  gueltig:=TryStrToFloat(s,d2);  if gueltig=false then exit; // absichtlich keine Fehlermeldung, können zuviele werden!  d2:=Abs(d2);   if d1=d2 then result:=0;      // beide Einträge haben die gleiche Sortier-Reihenfolge  if d1 > d2 then result:= 1;   // Sortierreihenfolge, allenfalls +/- vertauschen  if d1 < d2 then result:= -1; end;                                        

marcov:
To be Delphi compatible, use $mode Delphi.

Nicole:
Thank you for the answer.
I changed it to
{$mode Delphi}{$H+}
not sure, what H means.

and: It did not help in the Sort-thing.

KodeZwerg:
i tested with default {$mode objfpc}{$H+} switch.
no error, no hint, no warning.

can you provide a screenshot or some small demo app?

KodeZwerg:

--- Quote from: Nicole on September 09, 2022, 04:17:44 pm ---what H means
--- End quote ---
Hints  :)

turn hints on/off

Navigation

[0] Message Index

[#] Next page

Go to full version