AnnGetDistance2 example for Delphi

Procedure TForm1.ExampleAnnGetDistance2 ( hObject: HANNOBJECT );
var
    nObjectType: L_INT;
    lCount: L_INT32;
    dTotalDis: L_DOUBLE;
    lTotalRulerUnit: L_INT32;
    lTotalSmartUnit: L_INT32;
    dDistance: L_DOUBLE;
    lRulerUnit: L_INT32;
    lSmartUnit: L_INT32;
    i: L_INT;
begin
    nObjectType:= LEADAnn1.AnnGetType(hObject);

    if (nObjectType <> ANNOBJECT_RULER) then
    begin
       ShowMessage('This object is not an RULER Object');
    end;
    LEADAnn1.AnnGetDistance2(hObject);

    lCount:= LEADAnn1.AnnDistanceCount;

    dTotalDis:= LEADAnn1.AnnTotalDistance;
    lTotalRulerUnit:= LEADAnn1.AnnTotalRulerUnit;
    lTotalSmartUnit:= LEADAnn1.AnnTotalSmartUnit;
    ShowMessage ( 'Total Distance:=  ' + FloatToStr(dTotalDis) + Chr(13) +
                   'Total Ruler Unit:= ' + IntToStr(lTotalRulerUnit) + Chr(13) +
                  'Total Smart Unit:= ' + IntToStr(lTotalSmartUnit));

    for i := 0 to lCount-1 do
    begin
       dDistance:= LEADAnn1.AnnDistance[I];
       lRulerUnit:= LEADAnn1.AnnRulerUnit[i];
       lSmartUnit:= LEADAnn1.AnnSmartUnit[i];

       ShowMessage( 'Distance Index:= ' + IntToStr(i) +  Chr(13) +
                     'Distance:=  ' + FloatToStr(dDistance) + Chr(13) +
                    'Ruler Unit:= ' + IntToStr(lRulerUnit) + Chr(13) +
                    'Smart Unit:= ' + IntToStr(lSmartUnit));

    end;
end;