ON STOP phrase
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 Procedure Editor or AppBuilder, if the code was run from that tool.
Almost all STOP conditions are trappable with the ON STOP phrase. In two cases, the AVM may ignore ON STOP phrases. First, 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 it encounters an ON STOP before this point it ignores it. If it encounters an ON STOP phrase after this point, then the AVM executes the ON STOP. Similarly, if the AVM encounters an I/O blocking statement inside a user-defined function or a non-void method, the STOP condition is raised, and the AVM unwinds the procedure stack ignoring ON STOP phrases until it gets to a point above the user-defined function or non-void method call.
Syntax
label1
LEAVE [label2
]NEXT [label2
]RETRY [label1
]RETURN ...
Returns to the calling routine, or if there is no calling routine, returns to the OpenEdge Editor. The following table describes various RETURN cases:
Option Descriptionreturn-value
The CHARACTER string you provide is passed to the caller. The caller can use the RETURN-VALUE function to read the returned value. ERROR Raises ERROR in the caller and undoes the current subtransaction. ERRORreturn-value
Raises ERROR in the caller and undoes the current subtransaction. The CHARACTER string you provide is passed to the caller. The caller can use the RETURN-VALUE function to read the returned value.The AVM also creates anProgress.Lang.AppError
object and stores thereturn-value
in theReturnValue
property.Note: User-defined functions have different behavior since they must return the data type specified in the definition. See the "FUNCTION statement" section for more information. ERRORerror-object-expression
Raises ERROR in the caller and undoes the current subtransaction.The specified error object is created and populated according to your code. If this is anProgress.Lang.AppError
object, the caller can use the RETURN-VALUE function to read the setting of theReturnValue
property. NO-APPLY In a user-interface trigger, prevents the AVM from performing the default behavior for that event.You cannot specify ERROR within a user-interface trigger block or a destructor. You can specify the NO-APPLY option only within a user-interface trigger block.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.
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 findsSalesrep
records with the SHARE-LOCK condition. The user can update the values of aSalesrep
record in the frame and choose the Assign button to assign the new values to the database. If the user attempts to update aSalesrep
record that another user already has in the SHARE-LOCK condition, ther-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.By default, the STOP key aborts the procedure. The ON STOP phrase on the DO TRANSACTION block in the
r-ostop2.p
procedure captures the STOP condition and returns control to the procedure.
See alsoON ENDKEY phrase, ON ERROR phrase, ON QUIT phrase, RETURN statement, RETURN-VALUE function, STOP statement
OpenEdge Release 10.2B
|