Version 4.2.6 for Mainframes
 —  Statements  —

PRINT

PRINT [(rep)] [NOTITLE] [NOHDR] [(statement-parameters)]

nX

'text' ' [(attributes)]

nT 'c'(n) [(attributes )]
/ ['='] operand1 [(parameters)]

This document covers the following topics:

For an explanation of the symbols used in the syntax diagram, see Syntax Symbols.

Related Statements: AT END OF PAGE | AT TOP OF PAGE | CLOSE PRINTER | DEFINE PRINTER | DISPLAY | EJECT | FORMAT | NEWPAGE | SKIP | SUSPEND IDENTICAL SUPPRESS | WRITE | WRITE TITLE | WRITE TRAILER

Belongs to Function Group: Creation of Output Reports


Function

The PRINT statement is used to produce output in free format.

The PRINT statement differs from the WRITE statement in the following aspects:

Top of page

Syntax Description

Operand Definition Table:

Operand Possible Structure Possible Formats Referencing Permitted Dynamic Definition
operand1   S A G N A U N P I F B D T L   G O yes no

Syntax Element Description:

(rep)
Report Specification:

The notation (rep) may be used to specify the identification of the report for which the PRINT statement is applicable.

A value in the range 0 - 31 or a logical name which has been assigned using the DEFINE PRINTER statement may be specified.

If (rep) is not specified, the PRINT statement will apply to the first report (Report 0).

If this printer file is defined to Natural as PC, the report will be downloaded to the PC, see Example 2.

For information on how to control the format of an output report created with Natural, see Controlling Data Output (in the Programming Guide).

NOTITLE
Default Page Title Suppression:

Natural generates a single title line for each page resulting from a PRINT statement. This title contains the page number, the time of day, and the date. Time of day is set at the beginning of the session (TP mode) or at the beginning of the job (batch mode). This default title line may be overridden by using a WRITE TITLE statement, or it may be suppressed by specifying the NOTITLE clause in the PRINT statement. Examples:

  • Default title will be produced:

    PRINT NAME
  • User title will be produced:

    PRINT NAME WRITE TITLE 'user-title'
    
  • No title will be produced:

    PRINT NOTITLE NAME

If the NOTITLE option is used, it applies to all DISPLAY, PRINT and WRITE statements within the same object which write data to the same report.

NOHDR
Column Header Suppression:

The PRINT statement itself does not produce any column headers. However, if you use the PRINT statement in conjunction with a DISPLAY statement, you can use the NOHDR option of the PRINT statement to suppress the column headers generated by the DISPLAY statement. The NOHDR option only takes effect if the execution of the PRINT statement causes a new page to be output.

Without the NOHDR option, the column headers (if any) of the DISPLAY statement would be output on this new page; with NOHDR they will not.

statement-parameters
Parameter Definition at Statement Level:

One or more parameters, enclosed within parentheses, may be specified at statement level, that is, immediately after the PRINT statement or an element being displayed.

Each parameter specified in this manner will override any previous parameter specified in a GLOBALS command, SET GLOBALS (in Reporting Mode only) or FORMAT statement. If more than one parameter is specified, the parameters must be separated from one another by one or more blanks. A parameter entry must not be split between two statement lines.

The parameter settings applied here will only be regarded for variable fields, but they have no effect on text-constants. If you would like to set field attributes for a text-constant, they have to be set explicitly for this element, see Parameter Definition at Element (Field) Level.

See also:

nX, nT, / See Field Positioning, Text, Attribute Assignment below.

List of Parameters

Parameters that can be specified with the PRINT statement Specification (S = at statement level, E = at element level)
AD Attribute Definition SE
AL Alphanumeric Length for Output SE
CD Color Definition SE
CV Control Variable SE
DF Date Format SE
DL Display Length for Output SE
DY Dynamic Attributes SE
EM Edit Mask SE
FL Floating Point Mantissa Length SE
MC Multiple-Value Field Count S
MP Maximum Number of Pages of a Report S
NL Numeric Length for Output SE
PC Periodic Group Count S
PM Print Mode SE
SG Sign Position SE
ZP Zero Printing SE

The individual session parameters are described in the Parameter Reference.

Example of Parameter Usage at Statement and Element (Field) Level

Field Positioning, Text, Attribute Assignment

nX

 

'text' [(attributes)]

nT   'c' ( n ) [(attributes)]
/

['='] operand1  [(parameters)]

Field Positioning Notations

nX
Column Spacing:
This notation inserts n spaces between columns. n must not be zero.
PRINT NAME 5X SALARY
nT
Tab Setting:

The nT notation causes positioning (tabulation) to print position n. Backward positioning results in a line advance.

In the following example, NAME is printed beginning in position 25, and SALARY is printed beginning in position 50:

PRINT 25T NAME 50T SALARY
/
Line Advance - Slash Notation:

When placed between fields or text elements, a slash (/) causes positioning to the beginning of the next print line.

PRINT NAME / SALARY

Text/Attribute Assignment

'text'
Text Assignment:

The character string enclosed by single quotes is displayed.

PRINT 'EMPLOYEE' NAME 'MARITAL/STATUS' MAR-STAT
'c' (n)
Character Repetition:

The character enclosed by single quotes is displayed n times immediately before the field value.

PRINT '*' (5) '=' NAME
'='
Field Content Positioned behind Field Heading:

When placed before a field, the equal sign '=' results in the display of the field heading (as defined in the DEFINE DATA statement or in the DDM) followed by the field contents.

PRINT '=' NAME
operand1
Field to be Printed:

As operand1 you specify the field to be printed.

parameters
Parameter Definition at Element (Field) Level:

One or more parameters (see table above), enclosed within parentheses, may be specified immediately after operand1.

Each parameter specified in this manner will override any previous parameter specified at statement level or in a GLOBALS command, SET GLOBALS (in Reporting Mode only) or FORMAT statement.

If more than one parameter is specified, one or more blanks must be placed between each entry. An entry must not be split between two statement lines.

See also:

Output Attributes

attributes indicates the output attributes to be used for text display. Attributes may be:

AD=AD-value
BX=BX-value
CD=CD-value
PM=PM-value

AD-value
CD-value

For the possible session parameter values, refer to the corresponding sections in the Parameter Reference documentation:

Note:
The compiler actually accepts more than one attribute value for an output field. For example, you may specify: AD=BDI. In such a case, however, only the last value applies. In the given example, only the value I will become effective and the output field will be displayed intensified.

Top of page

Example

Example 1 - PRINT Statement

** Example 'PRTEX1': PRINT                                              
************************************************************************
DEFINE DATA LOCAL                                                       
1 EMPLOY-VIEW VIEW OF EMPLOYEES                                         
  2 NAME                                                                
  2 FIRST-NAME                                                          
  2 CITY                                                                
  2 JOB-TITLE                                                           
  2 ADDRESS-LINE (2)                                                    
END-DEFINE                                                              
*                                                                       
LIMIT 1                                                                 
READ EMPLOY-VIEW BY CITY                                                
  /*                                                                    
  WRITE NOTITLE 'EXAMPLE 1:'                                            
             // 'RESULT OF WRITE STATEMENT:'                            
  WRITE       /  NAME  ',' FIRST-NAME ':' JOB-TITLE '*' (30)            
  WRITE       / 'RESULT OF PRINT STATEMENT:'                            
  PRINT       /  NAME  ',' FIRST-NAME ':' JOB-TITLE '*' (30)      
  /*                                        
  WRITE      // 'EXAMPLE 2:'                
             // 'RESULT OF WRITE STATEMENT:'
  WRITE       /  NAME 60X ADDRESS-LINE (1:2)
  WRITE       / 'RESULT OF PRINT STATEMENT:'
  PRINT       /  NAME 60X ADDRESS-LINE (1:2)
  /*                                        
END-READ                                    
END                                        

Output of Program PRTXEX1:

EXAMPLE 1:                                                                    
                                                                              
RESULT OF WRITE STATEMENT:                                                    
                                                                              
SENKO                , WILLIE               : PROGRAMMER                      
******************************                                                
                                                                              
RESULT OF PRINT STATEMENT:                                                    
                                                                              
SENKO , WILLIE : PROGRAMMER ******************************                    
                                                                              
                                                                              
EXAMPLE 2:                                                                    
                                                                              
RESULT OF WRITE STATEMENT:                                                    
                                                                              
SENKO                                                                         
2200 COLUMBIA PIKE    #914                                                    
                                                                              
RESULT OF PRINT STATEMENT:                                                    
                                                                              
SENKO                                                            2200 COLUMBIA
PIKE  #914                                                                   

Example 2 - PRINT Statement with Report to be Downloaded to the PC

** Example 'PCPIEX1': PRINT to PC                                       
**                                                                      
** NOTE: Example requires that Natural Connection is installed.         
************************************************************************
DEFINE DATA LOCAL                                                       
01 PERS VIEW OF EMPLOYEES                                               
  02 PERSONNEL-ID                                                       
  02 NAME                                                               
  02 CITY                                                               
END-DEFINE                                                              
*                                                                       
FIND PERS WITH CITY = 'NEW YORK'                 /* Data selection      
  PRINT (7) 5T CITY 20T NAME 40T PERSONNEL-ID    /* (7) designates      
                                                 /* the output file    
                                                 /* (here the PC).      
END-FIND                                                                
END 

Top of page