π― 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
ejectstatements ingetFocusorleavePrintedtriggers for best results - π Always check the
$printingstatus before usingeject - β‘ Use
ejectstrategically 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! π¨βπ»β¨
Top comments (0)