🎯 What is the Close Command?
The close
command in Uniface is your go-to tool for logging off from specified database paths or network connections. Think of it as the proper way to "hang up the phone" when you're done talking to a database or network resource! 📞
🛠️ Basic Syntax
close {"PathName/net"}
Example:
close "$MY_PATH"
🔧 Key Parameters
PathName Parameter
- Data Type: String
- Purpose: Name of a DBMS or network path (like $MSS, $DATA, or $TCP)
- Important: The leading dollar sign ($) is required! 💰
The /net Qualifier
The /net
qualifier is special - it tells Uniface you're dealing with a TCP or TLS network path. Here's what you need to know:
- If you opened a path with
/net
, you must close it with/net
too! ⚖️ - For paths like
$DNP
,$TCP
, and$TLS
,/net
is implicit - Any path not recognized as a network path is assumed to be a DBMS path
📊 Return Values and Error Handling
$status Values
Value | Meaning |
---|---|
0 | ✅ Success! Path was closed successfully |
-3 | ❌ Exceptional I/O error (hardware or software) |
-16 | 🌐 Network error: unknown |
Common $procerror Values
- -2 through -12: Database I/O errors
- -16 through -30: Network I/O errors
- -1107: Path name issues (incorrect name, doesn't exist, or /net mismatch)
🎭 Different Behaviors Based on Path Type
🗄️ DBMS Paths
When you close a local or remote DBMS path:
- Closes all open tables and files for entities on that path
- Logs off from the database
- For remote DBMS paths, the network connection stays open (unless you use /net)
📁 Uniface File Server Paths
When closing a network path to a Uniface File Server:
- Closes all entities on the path
- Logs off from accessed databases
- With /net: also closes the network connection
🚀 Uniface Application Server Paths
When closing a network path to a Uniface Application Server:
- Closes all remote component instances
- Stops synchronous Uniface Server if applicable
- Closes exclusive Uniface Server if it's one
- With /net: also closes the network connection
💡 Best Practices
Always Commit or Rollback First! 🔄
Before closing a path that leads to DBMS tables or files, it's highly recommended to perform a commit
or rollback
. This ensures your application doesn't rely on unpredictable DBMS behavior and maintains consistency.
🔍 Practical Examples
Example 1: Graceful Exit
; trigger: Detail
if ($status = 1)
rollback
close
apexit
endif
Example 2: Close Specific Database
close "$MSS"
Example 3: Close User-Defined Path
close "$MY_PATH"
Example 4: Close All Paths
Simply call close
without any parameters to close all DBMS paths and network paths, including remote components! 🧹
🎪 Where Can You Use It?
Good news! The close
command is allowed in all component types. Whether you're working with forms, services, or any other Uniface component, you can use close
to manage your connections properly. 🎉
🔚 Conclusion
The close
command is an essential tool for proper resource management in Uniface applications. Remember to:
- Always match your
/net
qualifiers between open and close operations - Perform commits or rollbacks before closing DBMS paths
- Handle return values appropriately for robust error handling
- Use it in all component types as needed
Happy coding! 🚀✨
This article is based on the official Uniface Documentation 10.4 and was created with AI assistance to help make complex technical concepts more accessible to developers.