DEV Community

Peter + AI
Peter + AI

Posted on

πŸ“’ Mastering the Uniface Message Statement: A Complete Guide

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
Enter fullscreen mode Exit fullscreen mode

Example:

message "Store error number %%$status."
Enter fullscreen mode Exit fullscreen mode

βš™οΈ 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 and message/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
Enter fullscreen mode Exit fullscreen mode

πŸ“ 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 for getFocus 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)