• support@ifer.cz
  • +420 2 4195 0607

Using Exit and Abort commands

By Martin Cerny / Nov 30, 2016

Execution of the Field-Map scripts can be aborted by the Exit and Abort commands.

The Exit command stops execution of current script without further consequences for Field-Map operation. If Exit is being used in the script then the rest of the script after Exit command is skipped. Following simplified example demonstrates Exit command:

begin
  try
    ShowInformation ('Starting…');
    Exit;
    ShowInformation ('Continue after exit…');
  finally
    ShowInformation ('Leaving try..finally construct..');
  end;
end.

Dialog with message „Continue after exit…“ never happens, because it is after Exit command. However, the Exit command respects try..finally construct and therefore the block after finally is being executed – dialog with message „Leaving try..finally construct..“ will appear.

On the other hand the Abort commands has more consequences for ongoing operation of Field-Map. Abort will stop not only the execution of current script but also all following operations being performed by Field-Map. Abort should be used carefuly because of the consequences to Field-Map.

Logically, the Abort command is used mainly in Before.. events:

Layer events

BeforeDelete

BeforeEdit

BeforeInsert

BeforePost

BeforeImport

BeforeEmptyLayer

BeforeCreateNewPlot

BeforeOpenPlot

BeforeDeletePlot

BeforeBuildPolygons

BeforeNewPoint

BeforeMovePoint

BeforeNewCentroid

BeforeNewLine

Field-Map events

BeforeCloseFieldMap

BeforeRunDLL

BeforeSynchronization

BeforeRunDatabaseQueryTool

Remote diameter events

BeforeMesurement

BeforeHeightMeasurement

AfterHeightMeasurement

Height measurement events

BeforeMeasurement

Stem profile measurement events

BeforeProfileMeasurement

Stand density measurement events

BeforeStandDensityMeasurement

Angle count sampling events

BeforeAngleCountSampling

BeforeAngleCountMeasurement

When Abort command is being used in the script related to Before.. event it aborts Field-Map operation. Typical example is the use of Abort in BeforeDelete event. In BeforeDelete event it is possible to formulate some condition and if such condition is not met, then Abort the operation of record deletion. As a result the record will not be deleted:

begin
  if Shoots.RecordCount>0 then begin
    ShowInformation('Tree cannot be deleted – it has shoots.');
    Abort;
  end;
end.

Abort command respects try..finally construct too.


You must be logged in to post a comment