Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to watch/inspect a stringlist range in Delphi IDE?

I often find myself in the situation that I am debugging what is going on in part of a stringlist, e.g. data is being manipulated in the range StringList[StartOfBlock] to StringList[EndOfBlock]. One or more variable indexes in that range might be available that I can quickly inspect or watch, e.g. StringList[LineNum], but it is cumbersome to inspect neighbouring strings in the range StartBlock/Endblock. I can add another watch on StringList[LineNum+1], or modify the expression in the Ctrl-F7 inspector, but that is so much work ;-(

I would love to have StringList[StartOfBlock] to StringList[EndOfBlock] in the IDE in view permanently. (And it would be very nice if that view changes when StartOfBlock/EndOfBlock changes, or if that view can be refreshed.)

How would I build something 'into the IDE' to accomplish that?

like image 490
Jan Doggen Avatar asked Jan 26 '26 20:01

Jan Doggen


1 Answers

Create a global function:

function GetLines(AList: TStrings; AStart, AEnd: Integer): string;
var
  I: Integer;
begin
  Result := '';
  for I := AStart to AEnd do
    if I < AList.Count then
      Result := Result + AList[I] + sLineBreak;
end;

You can watch this function: GetLines(StringList, StartOfBlock, EndOfBlock) but enable function execution in watch settings (Allow function calls checkbox).

like image 137
hubalazs Avatar answered Jan 28 '26 11:01

hubalazs