Working with directories is a fundamental aspect of many applications, and Uniface provides a powerful and flexible way to create directories through the dircreate
statement. Let's dive into this essential ProcScript command! π
π― What is dircreate?
The dircreate
statement creates a specified directory in the current working directory using any file redirections defined in the assignment file. It's a simple yet powerful command that can be used across all Uniface component types.
Basic Syntax
dircreate NewDirPath
Simple Example
dircreate "exports"
βοΈ Parameters and Configuration
The dircreate
statement takes a single parameter:
Parameter | Data Type | Description |
---|---|---|
NewDirPath | String | Directory name, optionally preceded by the path to the directory. Must end with a directory separator. |
π Path Specifications
- Maximum Length: 255 bytes for any path, file name, or directory name
- Valid Separators: Backward slash (\), forward slash (/), and period (.) with square brackets ([a.b])
- Input Types: String, field, variable, or function that evaluates to a string
π Return Values
The dircreate
statement provides clear feedback through $procerror
:
Value | Error Constant | Meaning |
---|---|---|
0 | - | β Successful |
-13 | β OS command error occurred |
π‘ Pro Tip: Use /pri=64
to display the exact error message in the message frame when encountering OS command errors.
π οΈ Practical Examples
Creating a Directory in Current Working Directory
dircreate "coffee"
Creating a Directory in an Existing Directory
dircreate "sub1dir/coffee/"
Or using the alternative syntax:
dircreate "[.sub1dir.coffee.]"
π« Common Failure Scenarios
The dircreate
operation will fail if:
- π Directory already exists
- π Insufficient authorization level
- β Invalid syntax
- π· Specifies the $RES path (e.g., "$RES:/NewDirPath")
π₯οΈ Platform-Specific Behavior
Unix Systems
On Unix, directories are created with read and write access for world, group, and user levels. π§
iSeries Systems
On iSeries, dircreate
can create:
- Without IFS prefix: Libraries or files in libraries (max one directory separator)
- With IFS prefix: IFS directories with subdirectories (subject to file system rules)
π Best Practices
- Always check return values: Monitor
$procerror
for operation success - Use proper separators: Leverage Uniface's cross-platform directory separators
- Handle errors gracefully: Implement proper error handling for failed operations
- Validate paths: Ensure paths don't exceed 255 bytes
π Conclusion
The dircreate
statement is a versatile tool in the Uniface developer's toolkit. Whether you're organizing application data, creating export directories, or managing file structures, understanding this command will enhance your ProcScript capabilities. πͺ
Remember to always validate your directory paths and handle potential errors appropriately. Happy coding! π―
Based on Uniface Documentation 10.4 | Created with AI assistance
Top comments (0)