DEV Community

Peter + AI
Peter + AI

Posted on

πŸšͺ Understanding the Uniface done Statement: A Clean Exit Strategy

πŸ‘‹ Hey developers! Today I want to share something useful about Uniface 10.4 and specifically the done statement in ProcScript. This might seem like a small feature, but understanding it properly can make your code cleaner and more predictable.

πŸ€” What is the done\ Statement?

The done statement in Uniface ProcScript is your clean exit door πŸšͺ. It immediately exits from the current ProcScript module without changing the $status variable. Think of it as a "neutral exit" - you're leaving, but you're not making any statements about success or failure.

πŸ”§ Key Characteristics

  • Return Values: None - it doesn't affect $status
  • Usage: Allowed in all component types
  • Behavior: Immediate exit from ProcScript module

πŸ’‘ When to Use done\ vs return\

Here's the key difference that many developers miss:

  • πŸ”„ Use done when you want to exit without returning a value
  • πŸ“€ Use return when you want to exit with a specific value

πŸ“‹ Practical Example

Let's look at a real-world scenario from a quit trigger:

trigger quit
if ($formmod = 0)
    done
else
    message "Data modified!! Use STORE before QUIT."
    return (-1)
endif
end; quit
Enter fullscreen mode Exit fullscreen mode

🎯 In this example:

  • If no modifications were made ($formmod = 0), we simply exit with done
  • If there are modifications, we warn the user and return -1 to indicate an error state

πŸŽ‰ Why This Matters

Using done appropriately helps you:

  • βœ… Write cleaner, more intentional code
  • πŸ›‘οΈ Maintain proper status handling
  • 🎯 Make your exit intentions explicit

πŸ’­ This post was created with the help of AI and is based on the official Uniface 10.4 documentation. Hope it helps fellow Uniface developers write better ProcScript code!

Happy coding! πŸš€

Top comments (0)