DEV Community

Peter + AI
Peter + AI

Posted on

Understanding Uniface's lfilemove: Local File Operations Made Simple

When working with file operations in Uniface, developers often need to move files around the local filesystem. The lfilemove statement provides a clean and efficient way to handle this task while bypassing file redirections. Let me walk you through this powerful command! 📁

📋 What is lfilemove?

The lfilemove statement in Uniface 10.4 moves a local file to a local directory or renames it to a new file path. What makes it special is that it ignores any file redirections defined in the assignment file, giving you direct control over file operations.

🔧 Syntax and Usage

The syntax is straightforward:

lfilemove FilePath, DirPath | NewFilePath
Enter fullscreen mode Exit fullscreen mode

Here's a practical example:

lfilemove "./test1.txt", "./saved/text.txt"
Enter fullscreen mode Exit fullscreen mode

This command moves test1.txt from the current directory to the saved directory and renames it to text.txt.

📊 Parameters Breakdown

Parameter Data Type Description
FilePath String Source file name with optional path. Must not end with directory separator ⚠️
DirPath String Target directory with optional path. Must end with directory separator ⚠️
NewFilePath String New file name with optional path. Must not end with directory separator ⚠️

🎯 Return Values and Error Handling

The $procerror variable tells you if the operation succeeded:

  • 0: ✅ Success! The file was moved successfully
  • -13: ❌ UIOSERR_OS_COMMAND - An OS command error occurred

💡 Pro tip: If you encounter error -13, set /pri=64 to display the exact error message in the message frame for better debugging.

🌐 When to Use lfilemove vs Other Commands

Here's when to choose lfilemove:

  • Local file operations: Perfect for moving files within your local filesystem 🖥️
  • Bypassing redirections: When you need to ignore assignment file redirections
  • Component flexibility: Works in all Uniface component types

For network operations, consider using fileload instead. For simple renaming without moving, lfilerename or filerename are better choices.

💻 Real-World Examples

Here are some practical scenarios:

; Move a log file to archive directory
lfilemove "./logs/app.log", "./archive/app_backup.log"

; Move user upload to processing folder
lfilemove "./uploads/document.pdf", "./processing/document.pdf"

; Organize files by date
lfilemove "./temp/report.xlsx", "./reports/2024/january_report.xlsx"
Enter fullscreen mode Exit fullscreen mode

🔍 Key Takeaways

  • lfilemove is your go-to command for local file operations in Uniface
  • It bypasses file redirections, giving you direct control
  • Always check $procerror for operation success
  • Remember the directory separator rules for parameters
  • It's available in all component types, making it highly versatile

Working with file operations doesn't have to be complicated. With lfilemove, you have a reliable tool that gets the job done efficiently! 🎉

This article was created with AI assistance and is based on the official Uniface 10.4 documentation.

Top comments (0)