ON phrase syntax
- Last Updated: October 18, 2024
- 2 minute read
- OpenEdge
- Version 12.2
- Documentation
This is the full syntax for the ON phrase.
Note there are slightly different options for the different phrases. Specifically, only
ON ERROR has the THROW option. STOP conditions are thrown
by default, so there is no need to specify TRHOW in the ON
STOP syntax. ON ENDKEY and ON QUIT do not have the THROW option since
they are older constructs and do not participate in the newer structured error handling
model. In addition, ON QUIT does not require the UNDO
option, unlike the others.
|
|
|
- label1
- The name of the block whose processing you want to undo. If you do not name
a block with label1, the AVM undoes the
processing of the block started by the statement that contains the
ON ERROR/STOP/ENDKEYphrase. - LEAVE [label2]
- Indicates that after undoing the processing of a block, the AVM leaves the block labeled label2. If you do not name a block, the AVM leaves the block labeled with label1. There are restrictions. For example, you cannot undo an outer block, but leave only the inner block.
- NEXT [label2]
- Indicates that after undoing the processing of a block, the AVM executes the
next iteration of the block you name with the label2 option. If you do not name a block with the
NEXToption, the AVM executes the next iteration of the block that contains theONphrase. - RETRY [label1]
- Indicates that after undoing the processing of a block, the AVM repeats the
same iteration of the block.
Because
RETRYin a block without user input results in an infinite loop, the AVM automatically checks for this possibility and converts aRETRYblock into aLEAVEblock, or aNEXTblock, if it is an iterating block. This behavior is often referred to as infinite loop protection. - RETURN ...
- Returns to the calling routine, if there is one. The following table
describes various
RETURNoptions:Option Description return-value In procedures and VOID methods, this must be a CHARACTER string. The caller can use the RETURN-VALUEfunction to read the returned value. For user-defined functions, non-VOID methods and property getters, the value must match the specified return type.ERRORUndoes the current subtransaction, and raises ERRORin the caller. You cannot specifyERRORwithin a user-interface trigger block or a destructor.For user-defined functions see note below.
ERRORreturn-valueUndoes the current subtransaction, and raises ERRORin the caller. The CHARACTER string you provide is available to the caller in theRETURN-VALUEfunction. The AVM also creates anAppErrorobject and stores the return-value in theReturnValueproperty.For user-defined functions see note below.
ERRORerror-object-expressionUndoes the current subtransaction, and raises ERRORin the caller. The specified error object instance is thrown to the caller.For user-defined functions see note below.
NO-APPLYIn a user-interface trigger, prevents the AVM from performing the default behavior for the trigger event. Otherwise, the option is ignored. Note: UsingRETURN ERRORin a user-defined function sets the target variable of the function to the Unknown value (?) instead of raisingERRORin the caller. See Raise ERROR to the caller of a user-defined function for more detail. - THROW
-
Use this directive to explicitly propagate an error to the enclosing block, if there is one, otherwise to the caller. You can learn more about throwing error objects in Raise Conditions.