This document covers the following topics:
For explanations 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 |
                  								PRINT |
                  								SKIP |
                  								SUSPEND IDENTICAL SUPPRESS
                  								| WRITE TITLE |
                  								WRITE TRAILER 
               
Belongs to Function Group: Creation of Output Reports
The WRITE statement is used to produce output in free
                  										format.
               
The WRITE statement differs from the
                  										DISPLAY statement in the
                  										following respects:
               
Line overflow is supported. If the line width is exceeded for a line, the next field (or text) is written on the next line. Fields or text elements are not split between lines.
No default column headers are created. The length of the data determines the number of positions printed for each field.
A range of values/occurrences for an array is output horizontally rather than vertically.
See also the following topics in the Programming Guide:
| WRITE[(rep)] [NOTITLE] [NOHDR] | ||||||||
| [(statement-parameters)] | ||||||||
|  |   | n X |     | 
 | 'text' [(attributes)] | 
 |     | |
| n T | 'c'(n) [(attributes)] | |||||||
| x/y | ['='] operand1 [(parameters)] | |||||||
| T*field-name | ||||||||
| P*field-name | ||||||||
| / | ||||||||
For explanations of the symbols used in the syntax diagram, see Syntax Symbols.
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:
| Syntax Element | Description | 
|---|---|
| (rep) |  Report Specification: The notation
                                 																				 As report identification, a value in the range  If  If this printer file is defined to Natural as PC, the report will be downloaded to the PC, see Example 6. For information on how to control the format of an output report created with Natural, see Report Format and Control (in the Programming Guide). | 
| NOTITLE |  Default Page Title
                                 																				Suppression: Natural generates a single title line for each page
                              																				resulting from a  Examples: 
 Notes: 
 | 
| NOHDR |  Column Header Suppression: The  Without the  | 
| 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
                              																				 Each parameter specified will override the corresponding
                              																				parameter previously specified in a
                              																				 If more than one parameter is specified, they must be separated by one or more blanks from one another. Each parameter specification must not be split between two statement lines. Note: See also: | 
| nX,nT, x/y,T*field-name,P*field-name,'=',/ |  Field Positioning Notation:
                                 																				 See Field Positioning Notations in the section Output Format Definitions. | 
| 'text','c'(n),attributes,operand1,parameters |  Text/Attribute Assignment: See Text/Attribute Assignment in the section Output Format Definitions. | 
| Parameters that can be specified with the WRITE 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 | 
| EMU | Unicode Edit Mask | E | 
| FL | Floating Point Mantissa Length | SE | 
| IS | Identical Suppress | SE | 
| LS | Line Size | S | 
| 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 | 
| PS | Page Size * | S | 
| SG | Sign Position | SE | 
| UC | Underlining Character | S | 
| ZP | Zero Printing | SE | 
* The PS session
                  										parameter setting is not considered if the number of occurrences of an array
                  										exceeds the PS value.
               
The individual session parameters are described in the Parameter Reference.
See also the following topics in the Programming Guide:
DEFINE DATA LOCAL 1 VARI (A4) INIT <'1234'> /* Output END-DEFINE /* Produced * /* --------- WRITE 'Text' VARI /* Text 1234 WRITE (AD=U) 'Text' VARI /* Text 1234 WRITE 'Text' (AD=U) VARI (AD=U) /* Text 1234 WRITE 'Text' (AD=U) VARI /* Text 1234 END
See also Example 5 - WRITE Statement Using '=' and Parameters on Statement/Element (Field) Level.
|     | n X |     |     | ||||
| n T | |||||||
| x/y | 
 | 'text' [(attributes)] | 
 | ||||
| T*field-name | 'c' (n) [(attributes)] | ||||||
| P*field-name | [ '=']
                           																		operand1
                              																		[(parameters )] | ||||||
| / | 
For explanations of the symbols used in the syntax diagram, see Syntax Symbols.
| Syntax Element | Description | 
|---|---|
| nX |  Column Spacing:  This notation inserts
                              																				 Example: WRITE NAME 5X SALARY See also: 
 | 
| nT |  Tab Setting:  The  In the following example,  WRITE 25T NAME 50T SALARY See also: 
 | 
| x/y |  x/y Positioning:
                                 																				 The  See also Positioning Notation x/y (in the Programming Guide). | 
| T*field-name |  Field Related Positioning:  The notation  See also: 
 | 
| P*field-name |  Field and Line Related Positioning:
                                 																				 The notation  See also: 
 | 
| '=' |  Field Content Positioned behind Field
                                 																				Heading:  When placed before a field, the equal sign
                              																				 See also: | 
| / |  Line Advance - Slash Notation:
                                 																				 When placed between fields or text elements, a slash (/) causes positioning to the beginning of the next print line. Example: WRITE NAME / SALARY Multiple slash (/) notations may be used to cause multiple line advances. See also: 
 | 
| Syntax Element | Description | 
|---|---|
| 'text' |  Text Assignment:  The character string enclosed by single quotes is displayed. Example: WRITE 'EMPLOYEE' NAME 'MARITAL/STATUS' MAR-STAT See also: 
 | 
| 'c'(n) |  Character Repetition:  The character enclosed by single quotes is displayed
                              																				 For example: WRITE '*' (5) '=' NAME results in ***** SMITH See also Text Notation, Defining a Character to Be Displayed n Times before a Field Value (in the Programming Guide). | 
| attributes |  Field Representation and Color Attributes:
                                 																				 It is possible to assign various attributes for text/field display. These attributes and the syntax that may be used are described in the section Output Attributes below. Examples: WRITE 'TEXT' (BGR) WRITE 'TEXT' (B) WRITE 'TEXT' (BBLC) | 
| operand1 |  Field to be Written:    | 
| parameters |  Parameter Definition at Element (Field)
                                 																				Level:  One or more parameters, enclosed within parentheses, may
                              																				be specified at element (field) level, that is, immediately after
                              																				 If more than one parameter is specified, one or more blanks must be placed between each entry. An entry may not be split between two statement lines. See also: | 
attributes indicates the output attributes to be used for text display. Attributes can be:
| 
 |     | |
| 
 |  
                                    ad-value |     | 
Where:
ad-value,
                   cd-value and
                   pm-value denote the possible values of
                   the corresponding session parameters AD, CD and
                   PM described
                   in the relevant sections of the Parameter Reference
                   documentation.
               
The compiler actually accepts more than one attribute value for an output
                   field. For example, you can specify: AD=BDI. In such a case,
                   however, only the last value applies. In the given example, only the value
                   I becomes effective and the output field is displayed
                   intensified.
               
For an alphanumeric/Unicode constant (Natural data format A or U), you can
                   specify ad-value and/or
                   cd-value without preceding
                   CD= or AD=, respectively. The single value entered is
                   then checked against all possible CD values first. For
                   example: a value of IRE will be interpreted as intensified/red but
                   not as intensified/right-justified/mandatory. You cannot combine a single
                   cd-value or
                   ad-value with a value preceded by
                   CD= or AD=.
               
| WRITE[(rep)] [NOTITLE] [NOHDR] [USING] | 
 | FORM | 
 | operand1 | 
 | operand2   | 
 | 
| MAP | NO
                                 																		PARAMETER | 
For explanations of the symbols used in the syntax diagram, see Syntax Symbols.
Operand Definition Table:
| Operand | Possible Structure | Possible Formats | Referencing Permitted | Dynamic Definition | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| operand1 | C | S | A | no | no | |||||||||||||||
| operand2 | S | A | G | N | A | U | N | P | I | F | B | D | T | L | yes | no | ||||
Syntax Element Description:
| Syntax Element | Description | 
|---|---|
|  FORMor 
                              																		MAP |  Use of Predefined Form or Map Layout:
                                 																				 This option may be used to indicate that a form or map layout previously defined with the map editor is to be used. A map layout used in a  For the line spacing, the  | 
| operand1 |  Form or Map Name:    | 
| operand2or 
 |  Field to be Written:    If  The fields must agree in number, sequence, format, length and (for arrays) number of occurrences with the fields in the referenced form/map; otherwise, an error occurs. If  | 
| NOTITLE/NOHDR |  Title Line/Column Header Suppression:
                                 																				   | 
Example 5 - WRITE Statement Using '=' and Parameters on Statement/Element (Field) Level
Example 6 - Report Specification with Output File Defined to Natural as PC
** Example 'WRTEX1': WRITE (with '=', 'text', '/')                      
************************************************************************
DEFINE DATA LOCAL                                                       
1 EMPL-VIEW VIEW OF EMPLOYEES                                           
  2 FULL-NAME                                                           
    3 FIRST-NAME                                                        
    3 MIDDLE-I                                                          
    3 NAME                                                              
  2 CITY                                                                
  2 COUNTRY                                                             
END-DEFINE                                                              
*                                                                       
LIMIT 1                                                                 
READ EMPL-VIEW BY NAME                                                  
  /*                                                                     
  WRITE NOTITLE                                                         
        '=' NAME '=' FIRST-NAME '=' MIDDLE-I //                         
        'L O C A T I O N' /                                             
        'CITY:   ' CITY    /                                            
        'COUNTRY:' COUNTRY //
  /*                         
END-READ                     
END 
               										NAME: ABELLAN              FIRST-NAME: KEPA                 MIDDLE-I:       
                                                                            
L O C A T I O N                                                             
CITY:    MADRID                                                             
COUNTRY: E 
               								 
               								
               ** Example 'WRTEX2': WRITE (with nX, nT notation) ************************************************************************ DEFINE DATA LOCAL 1 EMPL-VIEW VIEW OF EMPLOYEES 2 NAME 2 JOB-TITLE END-DEFINE * LIMIT 4 READ EMPL-VIEW BY NAME WRITE NOTITLE 5X NAME 50T JOB-TITLE END-READ END
ABELLAN MAQUINISTA ACHIESON DATA BASE ADMINISTRATOR ADAM CHEF DE SERVICE ADKINSON PROGRAMMER
** Example 'WRTEX3': WRITE (with T* notation)                           
************************************************************************
DEFINE DATA LOCAL                                                       
1 EMPL-VIEW VIEW OF EMPLOYEES                                           
  2 NAME                                                                
  2 CITY                                                                
  2 SALARY (1)                                                          
END-DEFINE                                                              
*                                                                       
LIMIT 5                                                                 
READ EMPL-VIEW BY CITY STARTING FROM 'ALBU'                             
  DISPLAY NOTITLE CITY NAME SALARY (1)                                  
  AT BREAK CITY                                                         
    /*                                                                  
    WRITE / 'CITY AVERAGE:' T*SALARY (1) AVER(SALARY(1)) //       
    /*                                                                  
  END-BREAK                                                             
END-READ                                                                
END 
               										        CITY                 NAME           ANNUAL  
                                            SALARY  
-------------------- -------------------- ----------
                                                    
ALBUQUERQUE          HAMMOND                   22000
ALBUQUERQUE          ROLLING                   34000
ALBUQUERQUE          FREEMAN                   34000
ALBUQUERQUE          LINCOLN                   41000
                                                    
CITY AVERAGE:                                  32750
                                                    
                                                    
ALFRETON             GOLDBERG                   4800
                                                    
CITY AVERAGE:                                   4800 
               								 
               								
               ** Example 'WRTEX4': WRITE (with P* notation)                           
************************************************************************
DEFINE DATA LOCAL                                                       
1 EMPL-VIEW VIEW OF EMPLOYEES                                           
  2 NAME                                                                
  2 CITY                                                                
  2 BIRTH                                                               
  2 SALARY (1)                                                          
END-DEFINE                                                              
*                                                                       
LIMIT 3                                                                 
READ EMPL-VIEW BY CITY FROM 'N'                                         
  DISPLAY NOTITLE NAME CITY                                             
          VERT AS 'BIRTH/SALARY' BIRTH (EM=YYYY-MM-DD) SALARY (1)       
  SKIP 1                                                                
  AT BREAK CITY                                                          
    WRITE  / 'CITY AVERAGE' P*SALARY (1) AVER(SALARY (1)) //       
  END-BREAK                                                             
END-READ                                                                
END 
               										        NAME                 CITY           BIRTH   
                                            SALARY  
-------------------- -------------------- ----------
                                                    
WILCOX               NASHVILLE            1970-01-01
                                               38000
                                                    
MORRISON             NASHVILLE            1949-07-10
                                               36000
                                                    
                                                    
CITY AVERAGE                                   37000
                                                    
                                                    
BOYER                NEMOURS              1955-11-23
                                              195900
                                                    
                                                    
CITY AVERAGE                                  195900 
               								 
               								
               ** Example 'WRTEX5': WRITE (using '=', statement/element parameters)    
************************************************************************
DEFINE DATA LOCAL                                                       
1 EMPL-VIEW VIEW OF EMPLOYEES                                           
  2 NAME                                                                
  2 PERSONNEL-ID                                                        
  2 PHONE                                                               
END-DEFINE                                                              
*                                                                       
LIMIT 2                                                                 
READ EMPL-VIEW BY NAME                                                  
  WRITE NOTITLE (AL=16 NL=8)                                            
        '=' PERSONNEL-ID '=' NAME '=' PHONE (AL=10 EM=XXX-XXXXXXX) 
END-READ                                                                
END 
               										PERSONNEL ID: 60008339 NAME: ABELLAN TELEPHONE: 435-6726 PERSONNEL ID: 30000231 NAME: ACHIESON TELEPHONE: 523-341
** Example 'PCDIEX1': DISPLAY and WRITE 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        
  WRITE (7) TITLE LEFT 'List of employees in New York' /                
  DISPLAY (7)          /* (7) designates the output file (here the PC).
    'Location'  CITY                                                    
    'Surname'   NAME                                                    
    'ID'        PERSONNEL-ID                                            
END-FIND                                                                
END