exit
Exits the current component instance and returns to the previous or specified instance.
exit {Expression} {,InstanceName}
Example: exit (0), "MAINMENU"
Parameters
Parameter | Data Type | Description |
---|---|---|
Expression | Number | Expression that results in a number. Uniface evaluates the expression, converts it to an integer if necessary, and places the result in $status. The simplest form of Expression is a constant. To improve readability, parentheses (()) are often included as a part of Expression. |
InstName | String | Name of the target component instance. If
longer than 32 characters, it is truncated to that length. Trailing blanks are removed. If InstanceName is present, it must be an instance in the component pool that the user would return to at some point if the exit statement had not been used. Uniface returns to the named instance; intervening instances are closed. (Any assignments for renaming components are not considered by exit.) |
Return Values
The result of evaluating Expression is placed in $status. If Expression is omitted, $status defaults to 0. In either case, $procerror is 0.
Use
Allowed in all component types, but exit {Expression}{,InstName} is not allowed in self-contained Service and Report components.
Description
The exit statement immediately exits the current component and returns to the previous component or to the InstanceName specified.
In Form components, it overrides the normal processing of events by the structure editor. Any outstanding data validation is not performed and triggers that would otherwise be executed are not activated. In addition, the loseFocus trigger is not activated.
For example, an exit statement in the quit trigger of a component does not cause the exec operation of the component to be reactivated. If you want the exec operation to be reactivated (for example, to execute any statements after the edit statement in the exec operation), you should use a return statement instead of exit.
deleteinstance and exit
If the current component is a local component instance (started with activate), an implicit deleteinstance is executed after the exit to remove the instance.
If the component instance is a remote synchronous service, it is deleted on both the server and the client. However, it is strongly recommended that you use the return statement and have the client perform an explicit deleteinstance, rather than to rely on the implicit behavior of exit.
Note: If the component instance is a remote asynchronous service, it is deleted on the server only—the client is not informed of the deletion. For that reason, the exit statement is not allowed in a remote asynchronous service. Instead, you should perform an explicit deleteinstance on the client side.
Before the current instance exits, any child instances attached to it are removed. In each of the attached instances that contains an operation named CLEANUP, that operation is executed before the instance is removed. If the current instance (the one that issued the exit statement) contains an operation named CLEANUP, that operation is performed before the component is removed.
Exiting to a Named Instance
Exiting to a named component instance bypasses any triggers that would ordinarily be executed in the current instance, as well as in any intervening instances. In each instance that is exited, if it contains an operation named CLEANUP, that operation is executed before the instance is removed.
Exiting to a named component instance is generally used to skip quickly back to a specific instance. Trying to exit to an instance that is not in the component pool or that is not a parent of the current instance is a logical error in the application. In this case, the InstanceName argument is ignored and the current instance exits normally, as if the InstanceName argument were not present.
The following example returns to the previous component:
trigger accept $1 = CUSTNAME exit (1) end; accept
The following example returns to the form
MAINMENU, if the user enters Y
:
trigger quit askmess "Return to Main Menu?" if ($status = 1) ;if answer is "Y" exit (0), "MAINMENU" else return (-1) endif end; quit