This post was created with the help of AI and is based on Uniface Documentation 10.4.
As a Uniface developer, you'll sooner or later encounter the apexit
command. This powerful command can terminate an application immediately, but it should be used with caution. Here's everything you need to know about apexit
! π
π What is apexit
?
The apexit
command terminates the application session immediately. It has the same effect as pressing Ctrl+C or Break and brings your Uniface application to a complete halt.
π― Usage and Availability
- β Allowed in: Form, Report, and Service components
- β Not allowed in: Self-contained components
- π Return values: None
β οΈ Important Considerations
πΎ Data Security
It is strongly recommended to use a close
statement before apexit
to ensure all data is stored or updated:
close
apexit
π Trigger Behavior
When terminating the application, triggers that would normally be reactivated (like apStart
) are not activated.
πΆ Child Instance Management
If the component that executes apexit
has child instances (started with newinstance
or activate
), these are deleted before the application ends. Any existing Cleanup operation is executed in the process.
π Development Environment Warning
β οΈ Attention: If you execute apexit
while testing a component within the Uniface IDE, the entire IDE is terminated! The same happens when you enter quit
in the Debugger.
π‘ Practical Example
Here's a typical example of using apexit
in a Quit trigger:
trigger Quit
askmess "Do you want to leave this application?"
if ($status = 1)
rollback
close
apexit
endif
end
π apexit
and try-finally
Constructs
An important point: If apexit
is executed within a try
block, the finally
block is not executed because the current runtime context is deleted.
try
; Code here
apexit ; finally block will NOT be executed!
finally
; This code is never reached
endtry
π Best Practices
β Recommended Approach
Avoid terminating the entire application with ProcScript. Instead:
- Terminate all instances in a controlled way
- Let Uniface exit the application naturally when all instances are gone
π οΈ When apexit
is Unavoidable
If you must use apexit
:
- Place all module-related cleanup logic directly before the
apexit
statement -
Do not rely on
finally
blocks for important cleanup operations
π― Conclusion
The apexit
command is a powerful tool in Uniface that should be used thoughtfully. While it enables immediate application termination, it's often better to strive for controlled termination.
Always remember: Clean up first, then exit! π§Ήβ¨
Have you had experiences with apexit
? Share your stories in the comments! π¬
Top comments (0)