When working with Uniface applications, managing directories programmatically is a common requirement. Today, I'll walk you through the ldircreate
statement in Uniface 10.4 - a powerful command that creates directories while bypassing assignment file redirections. π
Note: This article is based on the official Uniface documentation 10.4, and I had assistance from AI in structuring this content.
π§ What is ldircreate?
The ldircreate
statement is designed to create directories in your current working directory. What makes it special is that it ignores any file redirections specified in the assignment file, giving you direct control over where your directories are created.
π Basic Syntax
ldircreate NewDirPath
Here's a simple example:
ldircreate "exports"
This creates an "exports" directory in your current working directory. π
π― Parameters
Parameter | Data Type | Description |
---|---|---|
NewDirPath |
String | Directory name, optionally preceded by the path to the directory, which can be in a zip archive. Must end with a directory separator. |
π Return Values
The command returns different values through $procerror
to indicate success or failure:
Value | Error Constant | Meaning |
---|---|---|
0 | - | β Successful |
-13 | UIOSERR_OS_COMMAND | β An error occurred while trying to perform the OS command |
π‘ Pro Tips
- Error Handling: Always check
$procerror
after usingldircreate
to ensure the directory was created successfully - Debugging: If you encounter errors, set
/pri=64
to display the exact error in the message frame π - Flexibility: You can use
ldircreate
in all component types, making it versatile for various scenarios
π ldircreate vs dircreate
While ldircreate
works similarly to dircreate
, the key difference is that ldircreate
ignores file redirections in the assignment file. This gives you more direct control over directory creation, especially in environments where assignment files might redirect operations.
πͺ Practical Example
; Create a reports directory
ldircreate "reports/"
; Check if the operation was successful
if ($procerror = 0)
; Directory created successfully
message "Reports directory created! π"
else
; Handle the error
message "Failed to create directory. Error: " + $procerror
endif
π― Conclusion
The ldircreate
statement is a straightforward yet powerful tool for directory management in Uniface applications. By understanding its parameters, return values, and behavior, you can implement robust directory creation logic in your applications. πͺ
Remember to always handle potential errors gracefully and test your directory operations in different environments to ensure consistent behavior across your deployment scenarios.
Top comments (0)