Describes the processing that occurs when the STOP condition occurs during a block. This condition occurs when a user presses
STOP, when a STOP statement is executed, or when certain internal conditions occur within the AVM. The
STOP key is usually mapped to
CTRL+BREAK (Windows) or
CTRL+C (UNIX). By default, the STOP condition undoes active transactions, block by block, until it reaches the outermost block or a block that traps the STOP condition. Control then returns to the point where the outmost procedures was executed, be that the command line or a development tool such as Progress Developer Studio for OpenEdge or AppBuilder.
Almost all STOP conditions are trap-able with the ON STOP phrase. In some cases, the AVM might ignore ON STOP phrases at certain levels of the call stack. For example, if the AVM executes a procedure that relies on a lost database connection, the AVM raises the STOP condition and unwinds the call stack until it gets to a level above all references to the lost database. If the AVM encounters an ON STOP before this point, the AVM ignores the phrase. If the AVM encounters an ON STOP phrase after this point, the AVM executes the ON STOP.
ON STOP UNDO
[ label1 ]
[ , LEAVE [ label2 ]
| , NEXT [ label2 ]
| , RETRY [ label1 ]
| , RETURN [ return-value |
ERROR [ return-value | error-object-expression ] |
NO-APPLY ]
]
|
This procedure lets you update the CreditLimit field for each Customer. If you enter a value greater than 100,000, the program raises the STOP condition. Since you specified an UNDO, RETRY for a STOP, the procedure starts the iteration over and allows you to enter another value.
FOR EACH Customer ON STOP UNDO, RETRY:
DISPLAY Customer.CustNum Customer.Name Customer.CreditLimit.
UPDATE Customer.CreditLimit.
IF Customer.CreditLimit > 100000 THEN STOP.
END.
|
The ON STOP phrase is especially useful to trap the STOP condition that results when a user cancels out of a record lock conflict in an application. The
r-ostop2.p procedure is a simple record navigation and update utility that finds
Salesrep records with the SHARE-LOCK condition. The user can update the values of a
Salesrep record in the frame and choose the Assign button to assign the new values to the database. If the user attempts to update a
Salesrep record that another user already has in the SHARE-LOCK condition, the
r-ostop2.p procedure freezes as a result of the record locking conflict. The AVM displays a message asking the user to wait for the other user to relinquish the lock on the record or to press the STOP key to abort the operation.