DEV Community

Peter + AI
Peter + AI

Posted on

πŸ–¨οΈ Understanding the Uniface skip Statement: A Developer's Guide to Print Line Control

This blog post was created with AI assistance based on the official Uniface 10.4 documentation.

When working with Uniface applications, especially when dealing with reports and printing, you'll often need precise control over how your output is formatted. The skip statement is a simple yet powerful tool that helps you manage line spacing in your printed documents. πŸ“„

πŸ” What is the skip Statement?

The skip statement is a ProcScript command in Uniface that allows you to skip a specific number of lines during printing operations. Think of it as adding blank lines to your printed output - similar to pressing Enter multiple times in a word processor.

ProcScript is Uniface's procedural programming language used to code application behavior and business logic.

πŸ“ Basic Syntax

The syntax is straightforward:

skip {Expression}
Enter fullscreen mode Exit fullscreen mode

Where Expression is the number of lines you want to skip. If you don't specify a number, it defaults to skipping one line.

πŸ’‘ Practical Examples

Example 1: Simple Line Skipping

skip 2  ; Skip 2 lines
skip    ; Skip 1 line (default)
skip 0  ; Skip 1 line (same as default)
Enter fullscreen mode Exit fullscreen mode

Example 2: Conditional Line Skipping

Here's a real-world example from invoice printing where you skip lines between different invoice dates:

trigger leavePrinted 
    ; Check if we're currently printing
    if ($printing = 1)
        compare/next (INVDATE) from "INVOICE"
        if ($result = 0)
            skip 2  ; Skip 2 lines for better readability
        endif
    endif
end; leavePrinted
Enter fullscreen mode Exit fullscreen mode

What this code does: When printing invoices, if the next invoice has a different date than the current one, it adds 2 blank lines for visual separation.

βš™οΈ Key Rules and Behaviors

πŸ”’ Printing Context Required

The skip statement only works when Uniface is actively printing. You can check this using the $printing system variable:

  • $printing = 1 means printing is active
  • $printing = 0 means not printing (skip statement will be ignored)

πŸ“„ Page Break Behavior

Smart page handling: If you try to skip more lines than remaining on the current page, Uniface automatically issues an eject (page break) and continues on the next page. πŸ”„

⚑ Immediate Execution

When Uniface encounters a skip statement, it executes immediately without activating other triggers on the current line.

🚫 What NOT to Do

  • Negative numbers: skip -1 is not supported
  • Using without printing context: Always check $printing first
  • Decimal numbers: Values are automatically truncated to integers

πŸ”§ Common Use Cases

Report Formatting

  • Adding space between sections
  • Creating visual breaks in data
  • Improving document readability

Invoice and Document Generation

  • Separating different customers
  • Adding space before totals
  • Creating professional-looking layouts

πŸ”„ Related Commands

The skip statement works well with other Uniface printing commands:

  • eject: Forces a page break
  • print: Main printing command
  • printbreak: Controls line breaking in printing

🎯 Best Practices

  1. Always check printing status: Use if ($printing = 1) before skip statements
  2. Use meaningful numbers: skip 2 for section breaks, skip 1 for small spacing
  3. Comment your code: Explain why you're skipping lines for future maintenance
  4. Test your output: Always preview printed results to ensure proper formatting

πŸš€ Getting Started

To start using the skip statement in your Uniface applications:

  1. Identify where you need line spacing in your reports
  2. Add the skip statement within your printing triggers
  3. Always wrap it in a printing context check
  4. Test your output and adjust the skip values as needed

The skip statement might seem simple, but it's an essential tool for creating professional, well-formatted printed documents in Uniface. Master this command, and you'll have much better control over your application's printed output! ✨

Happy coding! πŸ‘¨β€πŸ’»πŸ‘©β€πŸ’»

Top comments (0)