DEV Community

Peter + AI
Peter + AI

Posted on

Understanding Uniface 10.4: The 'set' Statement Explained πŸš€

This blog post was created with AI assistance to help developers understand Uniface concepts better.

What is the 'set' Statement? πŸ”§

The set statement in Uniface 10.4 is a simple but powerful command that changes the value of specific ProcScript functions to TRUE (which equals 1 in Uniface). Think of it like flipping a switch - it turns a function "on" by setting its value to 1.

Key Terms Explained πŸ“š

  • ProcScript: The programming language used in Uniface for business logic
  • Function: A built-in command that performs specific tasks
  • TRUE/FALSE: In Uniface, TRUE = 1 and FALSE = 0
  • Component Types: Different kinds of Uniface applications (forms, reports, services)

How Does 'set' Work? βš™οΈ

The syntax is straightforward:

set ProcScriptFunction
Enter fullscreen mode Exit fullscreen mode

When you use set, it activates the specified function by changing its value to 1 (TRUE). This is only possible with certain built-in functions that support this feature.

Practical Example πŸ’‘

Here's a real-world example using $occcheck (occurrence checking):

operation exec
; set $occcheck to TRUE to enable checking
 name = $1
 retrieve
 set $occcheck(INVOICE)  ; Enable checking for INVOICE entity
 edit NAME
end; exec
Enter fullscreen mode Exit fullscreen mode

In this example:

  • $occcheck is a function that controls data validation
  • set $occcheck(INVOICE) turns on checking for the INVOICE entity
  • This helps prevent data inconsistencies during editing

Return Values πŸ“Š

The set statement returns status codes in $status:

  • 0: Success! The function was reset properly βœ…
  • <0: Error - the function doesn't support set ❌

Where Can You Use It? 🏒

The set statement works in most Uniface components, but with exceptions:

  • βœ… Forms and interactive components
  • βœ… Most service types
  • ❌ Self-contained Reports
  • ❌ Certain Service types

Best Practices 🎯

  • Always check the documentation to see if a function supports set
  • Monitor $status after using set to handle errors
  • Use set strategically to enable features when needed
  • Remember that set turns functions ON - there might be corresponding commands to turn them OFF

Conclusion πŸŽ‰

The set statement is a fundamental tool in Uniface 10.4 for controlling function behavior. While simple in concept, it provides precise control over when certain features are active in your applications. Understanding how to use set effectively will help you build more robust and controllable Uniface applications.

Top comments (0)