Prepare for print

Command group Flag affected Reversible Execute on client Platform(s)
Reports and Printing YES YES NO All

Syntax

Prepare for print ([Ask for job setup][,Do not finish others]) {instance-name (parameters)}

Options

Ask for job setup If specified, the command opens the job setup dialog
Do not finish others If not specified, all reports in progress are terminated before the new report is started

Description

This command prepares Omnis for record-by-record report printing. You specify the report instance name and you can add a list of $construct parameters for the report instance. The default instance name is the name of the report class itself.

You must put Prepare for print after any Set report name, Select destination..., Set port nameSet print or export file nameSet sort field and Report parameter commands and before the first Print record command.

The Ask for job setup option opens the job setup dialog that lets you select the number of copies, paper trays, the printer, and so on, for the current print job.

Prepare for print has the Do not finish others option which when checked allows multiple reports to be in progress at the same time. If this is unchecked (the default) all reports in progress are terminated before the new report is started, which is compatible with earlier versions of Omnis.

The flag is set if the command is successful, errors cause a message to be displayed. If placed in a reversible block, the Prepare for print mode is canceled and the totals printed when the command is reversed.

All the Print commands give an error if no report is selected, or if the report is printed to a port and no port is selected.

When reports are printed record-by-record using Print record in a loop, the sort fields set up in the report class still trigger the subtotals. No sorting takes place and, therefore, you must take care in the choice of index. You can trigger subtotals from the method by including a variable on the first line of the report class, including it in the sort fields and then using the method to change its value when required.

The Prepare for print mode is terminated or cancelled by End print. You must include an End print after a Prepare for print even if a totals section is not required.

Example

# Print report record by record
Prompt for destination
If flag true
  Set main file {fAccounts}
  Set report name rMyReport
  Send to screen
  Prepare for print
  Find first on fAccounts.Code
  While flag true
    # tVar1 is a sort field placed on line 1 of the report
    # class used to trigger subtotal section 1
    Calculate tVar1 as fAccounts.Surname
    Print record
    Next
  End While
  End print
End If