Try OpenEdge Now
skip to main content
ABL Reference
ABL Syntax Reference : STOP statement
 

STOP statement

Signals the STOP condition and throws an associated Progress.Lang.Stop object in the current block. By default, the STOP condition stops processing a procedure, backs out the active transaction, and unwinds the call stack until it returns to the startup procedure or the Procedure Editor. You can change this behavior by including the ON STOP phrase on a block statement or by catching the associated Stop object using a CATCH block.

Syntax

STOP

Example

In any procedure, the outermost block that updates the database is the system transaction. In this procedure, the first iteration of the FOR EACH block starts a system transaction. The transaction ends when that iteration ends. Another transaction starts at the start of the next iteration. After you update the credit-limit field, the AVM prompts you to STOP. If you enter yes, the STOP statement stops the procedure and undoes any database modifications made in that transaction, as shown:
r-stop.p
DEFINE VARIABLE ans AS LOGICAL NO-UNDO.

FOR EACH Customer:
DISPLAY Customer.CustNum Customer.Name.
UPDATE Customer.CreditLimit.
ans = FALSE.
MESSAGE "Stopping now undoes changes to this record.".
MESSAGE "Do you want to stop now?" UPDATE ans.
IF ans THEN STOP.
END.
When you add the ON STOP phrase to the block statement of the previous procedure, it changes the default behavior of the STOP statement. In this procedure, the AVM allows you to re-enter the record when you choose to stop:
r-stop2.p
DEFINE VARIABLE ans AS LOGICAL NO-UNDO.

FOR EACH Customer ON STOP UNDO, RETRY:
DISPLAY Customer.CustNum Customer.Name.
UPDATE Customer.CreditLimit.
ans = FALSE.
MESSAGE "Stopping now undoes changes to this record."
    "Do you want to stop now?"
    VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO UPDATE ans.
IF ans THEN STOP.
END.

Notes

*Stop object support is available as a Technology Preview only in OpenEdge Release 11.7.
*Unless you coded an ON STOP phrase or CATCH block to trap the STOP condition, the STOP statement continues to back out of all blocks on the call stack.
*Almost all STOP conditions are trappable with the ON STOP phrase or a stop CATCH block. In some cases, the AVM might ignore STOP conditions 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 the ON STOP phrase or a compatible stop CATCH block before this point, the AVM ignores the phrase or CATCH block. If the AVM encounters the ON STOP phrase or a compatible stop CATCH block after this point, the AVM executes the directive specified in the phrase or the CATCH block, with the CATCH block taking precedence if the ON STOP phrase is on the same associated block.
*If you use the Startup Procedure (-p) parameter to start the ABL session, and if the startup procedure is still active, the default STOP action restarts the procedure.
*A terminal user can initiate the STOP condition by pressing STOP. This is usually mapped to CTRL+BREAK (Windows) or CTRL+C (UNIX). The actual mapping depends on your terminal and system configuration.

See also

Progress.Lang.Stop class