π Introduction
As a Uniface developer, you'll encounter the apstart
statement sooner or later. In this post, I'll explain what it's all about and how it's used in practice.
This post was created with the help of AI and is based on Uniface documentation 10.4.
π― What is apstart?
The apstart
statement is a central component of Uniface applications. It passes control of the application to the component manager and waits for user input.
π§ Basic Properties
- Only allowed in the apStart trigger of application shells
- Required in the apStart trigger of Uniface Server startup shells
- Optional in other application types (since newer versions)
π Return Values
The apstart
statement returns various values in $status
:
Value | Meaning |
---|---|
-1 |
An error occurred (details in $procerror ) |
Other value | Return value of the last component/operation |
β οΈ Common Error Codes
Error Code | Constant | Meaning |
---|---|---|
1402 |
<UPROCERR_STATEMENT> |
Statement not allowed in this trigger |
ποΈ Practical Usage
Typical Use Case
trigger apStart
; Start non-modal forms
activate "FORM1"
activate "FORM2"
activate "FORM3"
; Pass control to user
apstart
end; apStart
π‘οΈ Exception Handling
For robust applications, you should use exception handling:
trigger apStart
try
; Your initialization logic here
activate "MAIN_FORM"
apstart
catch
; Error handling
message "Error starting the application"
end
end; apStart
π¨ Special Properties
π Automatic Detection
Uniface automatically detects the activation of a sequence of non-modal forms and automatically passes control to the user after the last activate
.
π₯ Application Termination
β οΈ Important: If no forms are present in the component pool when apstart
is executed, the application terminates.
π― Best Practices
- Always use in apStart trigger
- Implement exception handling
- Activate at least one form before apstart
- No -1 return from components (risk of confusion with errors)
π Conclusion
The apstart
statement is a fundamental element for Uniface applications. It enables the clean transfer of control to the component manager and is essential for developing interactive applications.
This post is based on Uniface documentation 10.4 and was created with AI support. For further details, consult the official Uniface documentation.
Top comments (0)