When working with Uniface applications, effective message handling is crucial for providing user feedback and debugging information. Today, I'll walk you through one of Uniface's essential statements: putmess. π
π― What is putmess?
The putmess statement is a built-in Uniface function that appends text to the message frame. It's a simple yet powerful tool for displaying information to users or logging messages during application execution.
π Basic Syntax
putmess {MessageText}
π‘ Simple Example
putmess "Export complete."
π§ Parameters and Return Values
Parameters:
-
MessageText(String): The message content you want to display. If you omit this parameter, an empty line is added to the message frame.
Return Values: None
βοΈ Usage Guidelines
The putmess statement can be used in all component types except:
- Dynamic Server Pages
- Static Server Pages
Important Note: The statement is ignored in a receiveMessage trigger if the user is currently in the message frame when the trigger activates.
π₯οΈ Batch Mode Behavior
In batch mode, putmess writes messages directly to the screen or batch log file, depending on your operating system settings. This makes it particularly useful for background processing and automated tasks.
π Practical Example: Error Handling with putmess
Here's a real-world example showing how to use putmess for error handling and user feedback:
operation exec
CUSTNAME.CUSTOMER = $1
COUNTRY.CUSTOMER = $2
retrieve
if ($status < 0)
putmess "Retrieve problem. No printout."
apexit ; end application
else
print "SALESLASER","A"
putmess "Printout sent to LaserJet II"
endif
end; exec
In this example:
- π We attempt to retrieve customer data
- β If the retrieval fails (
$status < 0), we display an error message - β If successful, we print the data and confirm the action
π Pro Tips
- π¨ Use
putmessfor progress indicators in long-running operations - π Combine with the Uniface Debugger to dump message frame contents to files
- π± Remember that message frame contents are accessible via the
$putmessfunction - π Messages accumulate in the frame - they don't replace previous content
π Conclusion
The putmess statement is a fundamental tool in Uniface development that enhances user experience through clear communication. Whether you're building error handling, progress tracking, or simple notifications, mastering putmess will make your applications more user-friendly and debuggable.
This article is based on the official Uniface 10.4 documentation and was created with assistance from AI to help fellow developers understand this essential Uniface feature better. π€
Top comments (0)