In the world of Uniface development, creating responsive and dynamic user interfaces is crucial for a great user experience. One powerful command that stands out for achieving this is the show statement. Far from merely presenting information, show is your secret weapon for instantly refreshing your application’s display without interrupting the flow of your code.
What is the Uniface show Statement?
At its core, the show statement is a ProcScript command designed to immediately update or refresh the visual elements of your Uniface form components. Unlike its counterparts, edit and display, which pause your application’s execution to await user interaction, show operates silently in the background, allowing your code to continue running while the interface updates. This non-blocking nature is what makes it incredibly valuable for live feedback and dynamic content.
The Simplicity of Syntax
Getting started with show is remarkably straightforward:
show
That’s it! This concise command triggers a powerful sequence of events behind the scenes.
How Does It Work Under the Hood?
When Uniface encounters a show statement, it performs several key actions:
- Display Synchronization: All visible field values on the form are updated to reflect their current state.
- Property Refresh: The current property values of components are refreshed (with the exception of entity properties for current occurrences).
- No Triggering of Events: Importantly, this update occurs without firing any associated component or field triggers, ensuring a clean and controlled refresh.
- Uninterrupted Execution: Your ProcScript continues to run immediately after
showis executed, without waiting for any user input.
Where Can You Use It? (And Where Not To!)
The show statement is specifically designed for form components. It’s essential to remember this limitation; attempting to use show within service components will result in an error (-1402, UPROCERR_STATEMENT).
A Practical Example: The Live Countdown
To truly grasp the power of show, consider a common scenario: a live countdown timer. Here’s how you might implement it in Uniface:
function CountDown()
variables
numeric j
endvariables
MyField.MyEnt = 10
while (MyField.MyEnt > 0)
show ; Instantly update the display
j = 10000 ; Create a small delay
while (j>0)
j = j - 1
endwhile
MyField.MyEnt = MyField.MyEnt - 1 ; Decrease the counter
endwhile
end; CountDown
In this example, show plays a critical role, ensuring that each decrement of MyField.MyEnt is immediately visible to the user, providing real-time feedback. The small delay is added to make the countdown perceptible.
Optimizing Display Updates: The AsynchGui Setting
If you experience issues with incomplete screen updates, Uniface provides a configuration setting to address this. Modifying the AsynchGui setting in your usys.ini file can force more thorough display refreshes:
AsynchGui = 2 ; Flush mode for complete screen updates
Common Scenarios for show
The versatility of show makes it indispensable for various application features:
- Progress Indicators: Keep users informed during lengthy operations by updating progress bars or status messages in real-time.
- Live Data Monitoring: Display dynamically changing values, such as stock prices or sensor readings, as they update.
- Status Updates: Provide instant feedback on ongoing background processes.
- Interactive UI Elements: Create dynamic and responsive user interfaces where elements change based on application logic without user intervention.
Performance Considerations
While powerful, it’s important to use show judiciously. Because it forces an immediate screen update, frequent calls within tight loops can potentially impact performance. For the best user experience, especially in rapid iterations, consider introducing slight delays between updates.
show vs. edit vs. display
To clarify show‘s unique role, let’s compare it with related statements:
edit: Displays a form and pauses execution, waiting for user input.display: Shows a read-only form and pauses execution, waiting for user interaction.show: Updates the display without pausing execution, allowing your code to continue.
Uniface Pro Tips
- Leverage
showto build truly responsive and engaging user interfaces. - It’s perfect for conveying progress during batch processes.
- Always remember its limitation to form components only.
- Combine it with
$interactiveand$editmodefor sophisticated form control.
Conclusion
The Uniface show statement is a fundamental tool for any developer aiming to create dynamic and user-friendly applications. Its ability to refresh the UI in real-time without halting code execution opens up a world of possibilities for progress indicators, live data updates, and interactive experiences. Master show, and you’ll significantly enhance the responsiveness and perceived quality of your Uniface applications.
Happy coding!