The message
statement in Uniface is a powerful tool for displaying information to users in various ways. Whether you're building desktop applications or web-based solutions, understanding how to effectively communicate with your users is crucial. In this comprehensive guide, we'll explore all aspects of the Uniface message statement based on the official Uniface 10.4 documentation (with a little help from AI to structure this content! π€).
π― What is the Message Statement?
The message
statement displays a specified string in the message line (if available) or in an interactive dialog box. It's your go-to command for user communication in Uniface applications.
Basic Syntax π
message{/nobeep}{/error | /warning | /info} MessageText
message/clear MessageText
message/hint MessageText
Example:
message "Store error number %%$status."
βοΈ Available Qualifiers
Qualifier | Description |
---|---|
/nobeep |
π Prevents audio signal when message is displayed (no effect in web environment) |
/info |
βΉοΈ Displays message in dialog box with info icon |
/warning |
β οΈ Displays message in dialog box with warning icon |
/error |
β Displays message in dialog box with error icon |
/clear |
π§Ή Clears the message line |
/hint |
π‘ Displays message without logging in history or beeping |
π Parameters and Return Values
Parameters
- MessageText (String): Text to display with a maximum length of 512 bytes
Return Values
None β
ποΈ Usage in Different Components
The message statement has different usage patterns depending on your component type:
- Form and Static Server Page Components: All qualifiers allowed β
- Service and Report Components:
/error
,/warning
,/info
,/clear
, and/nobeep
allowed - Form, Service, and Report Components: Basic
message
andmessage/hint
allowed
π Web Environment Considerations
When working in web environments, keep these important points in mind:
- Dynamic Server Pages: Use
webmessage
statement for better icon support and size control π¨ - Static Server Pages: Message types are prefixed as text (e.g.,
[info] This is my message.
) - Modern Browsers: Messages without switches or with
/hint
have no effect in contemporary browsers
π» Practical Example
Here's a real-world example showing how to handle store operations with proper error messaging:
trigger store
if ($status < 0)
message "Store error number %%$status."
rollback
endif
end; store
π Best Practices
- Keep it concise: Remember the 512-byte limit π
- Choose appropriate severity: Use
/error
,/warning
, or/info
wisely - Consider your environment: Web vs. desktop behavior differs significantly
- Use
/hint
for field guidance: Perfect forgetFocus
triggers π― - Log important messages: Use
$putmess
for file logging when needed
π Conclusion
The Uniface message statement is an essential tool for creating user-friendly applications. By understanding its various qualifiers and environment-specific behavior, you can create more intuitive and informative user experiences. Whether you're displaying simple hints or critical error messages, the message statement has you covered! π
Happy coding with Uniface! π¨βπ»π©βπ»
Top comments (0)