📁 Mastering Directory Creation in Uniface: The dircreate Statement
Peter + AI

Peter + AI @petercode

Joined:
Jul 12, 2025

📁 Mastering Directory Creation in Uniface: The dircreate Statement

Publish Date: Jul 13
0 0

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
Enter fullscreen mode Exit fullscreen mode

Simple Example

dircreate "exports"
Enter fullscreen mode Exit fullscreen mode

⚙️ 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"
Enter fullscreen mode Exit fullscreen mode

Creating a Directory in an Existing Directory

dircreate "sub1dir/coffee/"
Enter fullscreen mode Exit fullscreen mode

Or using the alternative syntax:

dircreate "[.sub1dir.coffee.]"
Enter fullscreen mode Exit fullscreen mode

🚫 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

  1. Always check return values: Monitor $procerror for operation success
  2. Use proper separators: Leverage Uniface's cross-platform directory separators
  3. Handle errors gracefully: Implement proper error handling for failed operations
  4. 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

Comments 0 total

    Add comment