File selection dialogs are a fundamental part of modern application development, and Uniface 10.4 provides a powerful filebox
statement that makes implementing file selection seamless and platform-native. Whether you're building enterprise applications or desktop tools, understanding how to effectively use filebox can significantly enhance your user experience. π
This article is based on the official Uniface Documentation 10.4, with AI assistance helping to structure and present the information in a developer-friendly format.
π― What is filebox?
The filebox
statement in Uniface displays a native GUI file selection dialog that automatically adapts to your platform. It's incredibly versatile, supporting both file and folder selection, with robust filtering capabilities and intelligent default behavior.
Basic Syntax
filebox{/save | /dir | /savenocheck} {Filter {, DefaultDirectory} }
π§ Key Features and Qualifiers
/save - Create New Files
Perfect for save dialogs where users need to specify a new filename:
filebox/save "*.txt", "C:/Documents/"
/savenocheck - Silent Overwrite
When you need to overwrite files without confirmation prompts:
filebox/savenocheck "*.log", "C:/temp/"
/dir - Folder Selection
Switches the dialog to folder selection mode:
filebox/dir
β οΈ Note: You cannot combine /dir
with /save
or use filters when selecting directories.
π¨ Advanced Filtering Techniques
Single File Type
filebox "*.xml"
Multiple File Types (Windows)
filebox "*.png;*.gif;*.jpg", "D:/images/"
Filter with Description
filebox "*.json=JSON Files", "D:/work/uniface/"
π Return Values and Error Handling
Understanding filebox return values is crucial for robust applications:
$status Value | Description |
---|---|
< 0 | Error occurred (check $procerror) |
0 | User cancelled selection |
1 | File selected successfully ($result contains path) |
Example Error Handling
filebox "*.dat", "C:/data/"
if ($status = 1)
; File selected successfully
message "Selected: ", $result
elseif ($status = 0)
; User cancelled
message "Selection cancelled"
else
; Error occurred
message "Error: ", $procerror
endif
π‘ Pro Tips and Best Practices
π Platform Compatibility
Always ensure your directory paths end with the appropriate separator:
- Windows:
"C:/temp/"
- Unix/Linux:
"/tmp/"
π Character Mode Fallback
In character mode environments, filebox automatically provides a text-based alternative, ensuring your applications work everywhere.
π Customizing Dialog Text
You can customize the dialog text by editing Uniface message text 4805 for better localization and user experience.
π Real-World Examples
Image File Selector
; Select image files with preview-friendly formats
filebox "*.png;*.gif;*.jpg;*.bmp=Image Files", "D:/images/"
Export File Dialog
; Save export files with automatic extension
filebox/save "*.exp;*.xml=Export Files", "C:/exports/"
Configuration Directory Picker
; Let users choose configuration directory
filebox/dir
π Conclusion
The Uniface filebox statement is a powerful tool that simplifies file selection while maintaining platform consistency. Its flexibility in handling different file types, directories, and error conditions makes it indispensable for modern Uniface applications. πͺ
Whether you're building data import features, configuration managers, or document processors, mastering filebox will significantly improve your application's usability and professional appearance.
Have you used filebox in your Uniface projects? Share your experiences and tips in the comments below! π
Top comments (0)