Posted on
🚀 Mastering File Operations in Uniface: The filemove Statement Guide
Hey fellow developers! 👋 Today I want to share some insights about file operations in Uniface, specifically thefilemove
statement. This comprehensive guide is based on the official Uniface Documentation 10.4, and I've got some help from AI to structure this content for you.
📋 What is filemove?
Thefilemove
statement is a powerful Uniface command that allows you to move files from one location to another. It's more flexible than you might think - you can move files between directories, rename them during the move, and even work with ZIP archives! 📦
🔧 Syntax and Parameters
The basic syntax is straightforward:
filemove FilePath, DirPath | NewFilePath
Parameters Breakdown:
Parameter | Type | Description |
---|---|---|
FilePath | String | Source file path (must not end with directory separator) |
DirPath | String | Target directory path (must end with directory separator) |
NewFilePath | String | New file path for move + rename (must not end with directory separator) |
✅ Return Values
Thefilemove
statement returns different values through$procerror
:
- 0: Success! 🎉
- -13: OS command error (use
/pri=64
to see details)
💡 Practical Examples
Simple Move to Another Directory
filemove "sub1dir/test.txt", "sub1dir/sub2dir/"
Or using bracket notation:
filemove "[.sub1dir]test.txt", "[.sub1dir.sub2dir]"
Move + Rename in One Operation
filemove "./test1.txt", "./sub2dir/text.txt"
Pro Tip: 💡 The presence or absence of the trailing directory separator determines whether you're just moving or also renaming!
🗜️ Working with ZIP Archives
One of the coolest features offilemove
is its ability to work with ZIP archives. You can:
- Move files within the same ZIP archive
- Move files between different ZIP archives
- Move files from ZIP archives to local directories
- Move files from local directories to ZIP archives
⚠️ Important Considerations
File Path Limitations
- Maximum path length: 255 bytes
- No wildcards allowed (except for specific directory functions)
- Multiple directory separator formats supported
Cross-Platform Behavior
Uniface automatically handles text file conversions when moving files across platforms, adjusting EOL characters and character sets. Binary files are copied as-is. 🌐
Common Failure Scenarios
- Source file doesn't exist or isn't a file
- Target directory doesn't exist or lacks write permissions
- Target file already exists
- Invalid syntax in path specifications
🎯 Best Practices
- Always check
$procerror
after file operations - Use forward slashes for cross-platform compatibility
- Ensure target directories exist before moving files
- Handle file collisions by checking if target files exist
- Consider using
filerename
for simple rename operations
🏁 Conclusion
Thefilemove
statement is an essential tool in the Uniface developer's toolkit. Its flexibility with ZIP archives, cross-platform support, and simple syntax make it perfect for file management tasks in your applications. Remember to always handle errors properly and consider the specific requirements of your target platform! 🚀
Happy coding! 👨💻👩💻
Top comments(0)
For further actions, you may consider blocking this person and/orreporting abuse