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)