🎯 What is the eject Statement?
The eject
statement in Uniface is a powerful tool for controlling page breaks when printing reports or forms. Think of it as your "new page" command that forces Uniface to continue printing on the next page. 📋
🔧 How Does It Work?
The eject
statement is straightforward to use but comes with specific rules and return values you need to understand:
📊 Return Values
$status Value | Description |
---|---|
0 | ✅ eject was successful |
-1 | ❌ An error occurred ($procerror contains details) |
⚠️ Common Errors
When eject
fails, you'll typically see:
- Error -1404 (UPROCERR_NO_PRINTING): Not currently printing ($printing is 0)
📍 Where Can You Use eject?
✅ Allowed in:
- Form components
- Report components
- getFocus trigger of entities
- leavePrinted trigger of entities
❌ Not allowed in:
- getFocus trigger of header or footer frames
🚫 When eject is Ignored
The eject
statement won't work in these scenarios:
- 🔴 When Uniface is not printing ($printing = 0)
- 🔴 In the second or later occurrence of an entity with horizontal repetition
- 🔴 On an empty page
- 🔴 In the getFocus trigger of header/footer frames
💡 Practical Example
Here's a real-world example that starts a new page when the invoice date changes:
trigger leavePrinted
compare/next (INVDATE) from "INVOICE" ;test if next date the same (or exists)
if ($result = 0) ;if next date exists and not the same
eject ;start printing on new page
endif
end
This code snippet demonstrates how to use eject
to group invoices by date, creating a new page for each date change. 📅
🎯 Best Practices
- 💡 Place
eject
statements ingetFocus
orleavePrinted
triggers for best results - 🔍 Always check the
$printing
status before usingeject
- ⚡ Use
eject
strategically to improve report readability and organization
🔚 Conclusion
The eject
statement is a simple yet powerful feature in Uniface that gives you precise control over page breaks in your reports and forms. Understanding when and how to use it effectively can significantly improve the presentation of your printed output. 🎨
Remember to handle the return values properly and be aware of the situations where eject
is ignored to avoid unexpected behavior in your applications!
Happy coding! 👨💻✨