How to traverse all liveblocks of workflow diagram

Here is a snippet of code from the TMS Diagram Studio "getting links" demo, which shows all incoming and ongoing links of a specific block, and what other blocks are connected to it. With this code you can check the next blocks (in diagram), check if they are a task block and then get the status list from it:


procedure TForm1.CheckBlockLinks(ABlock: TCustomDiagramBlock);

  procedure CheckLink(ALink: TCustomDiagramLine);
  var
    ConnectStr: string;
    ConnectedControl: TDiagramControl;
    ConnectedName: string;
  begin
    {A link has two connection points. We must find out which point has
     the block we are analysing, and which point has the other connected block
     (if any)}
    if ALink.SourceLinkPoint.Anchor = ABlock then
    begin
      ConnectedControl := ALink.TargetLinkPoint.Anchor;
      ConnectStr := '-->';
    end else
    begin
      ConnectedControl := ALink.SourceLinkPoint.Anchor;
      ConnectStr := '<--';
    end;

    if ConnectedControl = nil then
      ConnectedName := 'none'
    else
      ConnectedName := ConnectedControl.Name;
    Memo1.Lines.Add(Format('%s (%s) %s %s',
      [ConnectStr, ALink.Name, ConnectStr, ConnectedName]));
  end;

var
  c: integer;
  d: integer;
begin
  Memo1.Lines.Add(Format('%s links:',[ABlock.Name]));

  {Iterate through each link point (connection point) available in block}
  for c := 0 to ABlock.LinkPoints.Count - 1 do
    {For each link point, iterate through the controls which are anchored to it}
    for d := 0 to ABlock.LinkPoints[c].AnchoredCount - 1 do
    begin
      {If the anchored control is a line, then analise it.
       * for now, only lines can be anchored to a link point, so this
         test is not needed. But in a future version other types of
         controls can be anchored to a link point, so do the test already}
      if ABlock.LinkPoints[c].Anchoreds[d].DControl is TCustomDiagramLine then
        CheckLink(TCustomDiagramLine(ABlock.LinkPoints[c].Anchoreds[d].DControl));
    end;

  Memo1.Lines.Add('---');
end;