Forum > FPC development
Bug in StringLists
(1/1)
apexcol:
I have problems with TStringList...
--- 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";}};} ---procedure TotaliseByNames;var SL : TStringList; I1, I3 : integer; vElement: TDOMElement; vInputList: TDOMNodeList;begin // vInputList is out of scope but is another TStringList SL := TStringList.Create; SL.Sorted := true; for I1 := 0 to pred(vInputList.Count) do begin vElement := vInputList[I1]; SL.Find(vElement['name'], I3); if I3 = -1 then // does not exist then SL.AddObject(vElement['name'], vElement) // create the first else begin {some other code that modifies vElement with aritmethic operations...} end; FAnotherList.Assign(SL); end;
on the Finding it breaks the program...
Also I tried with IndexOf and it shows a number like 8261232 instead of -1,
I checked the code inside and it has some things to fix, for example
in stringl.inc line 936 instead of Result:=Result+1; it must be inc(Result), and
on sorted list, the add or insert method ought to add it on the right place.
bytebites:
--- 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";}};} --- if SL.Find(vElement['name'], I3) then begin {some other code that modifies vElement with aritmethic operations...} end else SL.AddObject(vElement['name'], vElement)
rvk:
Why open three posts/topics for this?
I answered here:
http://forum.lazarus.freepascal.org/index.php/topic,37880.msg255895.html
Navigation
[0] Message Index