Posted on
Understanding the Uniface Display Statement: Creating Read-Only Forms 📖
What is the Display Statement? 🎯
Thedisplay
statement in Uniface is a powerful tool that presents forms on the screen asdisplay-only, meaning users can view the data but cannot modify it. This is particularly useful for creating read-only interfaces or confirmation screens.
Basic Syntax 📝
display{/menu} {LitFieldName}
Example:
display CLIENT_DETAIL
Key Features and Parameters 🔧
Qualifiers
- /menu - Activates the menu trigger at field, entity, form, or application level when the form appears
Parameters
- LitFieldName (Literal) - The name of the field where the cursor should be positioned
- Don't enclose in quotation marks
- If omitted, cursor positions on the first painted field (top-left corner)
Return Values 📊
The$status
variable returns different values based on user actions:
Value | Meaning |
---|---|
10 | User used ^QUIT to leave the form |
9 | User used ^ACCEPT to leave the form |
0 | Success |
-16 | Application running in batch mode |
Common Error Codes ⚠️
Watch out for these common errors returned by$procerror
:
- -33 - Statement not allowed in batch mode
- -1401 - Prompted field not valid
- -1402 - Statement not allowed in this trigger (must be in exec operation)
Practical Example 💡
Here's a real-world example showing how to use the display statement:
operation exec CUST_NBR = $1 retrieve message "%%$hits customers match search profile" display CUSTNAMEend; exec
This code:
- Sets the customer number from a parameter
- Retrieves the customer data
- Shows a message with the number of matches
- Displays the customer name field in read-only mode
Important Usage Notes 📌
- ✅ Can only be used inForm components
- ✅ Must be within anexec operation
- ✅ Alternative: Use
newinstance
withDISPLAY=TRUE
- ✅ Alternative: Use
run/display
to start forms in display-only mode - ⚠️ Test for
$batch
to avoid batch mode errors
Best Practices 🏆
- Always handle the return values to provide proper user feedback
- Use meaningful field names for cursor positioning
- Consider the user experience when choosing between display modes
- Test your forms in different scenarios to ensure proper behavior
Conclusion 🎉
The Unifacedisplay
statement is an essential tool for creating read-only user interfaces. By understanding its syntax, parameters, and return values, you can build more robust and user-friendly applications.
Have you used the display statement in your Uniface projects? Share your experiences in the comments below! 💬
This article is based on the official Uniface Documentation 10.4 and was created with AI assistance to help developers understand this important feature.
Top comments(0)
For further actions, you may consider blocking this person and/orreporting abuse