To prevent a permanent loop from occurring within an ON-unit, use the following code segment:
on Error begin;
on Error System;
.
.
.
end;
If your program is caught in an endless loop, your primary concern is to be able to get out of the loop without shutting down your machine. The following solution is recommended for handling endless loops: