What is the Display Statement? π―
The display
statement in Uniface is a powerful tool that presents forms on the screen as display-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 CUSTNAME
end; 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 in Form components
- β Must be within an exec 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 Uniface display
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)