Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 8 Printing 1. In COBOL you send data to the printer by writing data to a file. In COBOL, the printer is defined as a file, and it is opened, closed,

Similar presentations


Presentation on theme: "Chapter 8 Printing 1. In COBOL you send data to the printer by writing data to a file. In COBOL, the printer is defined as a file, and it is opened, closed,"— Presentation transcript:

1 Chapter 8 Printing 1

2 In COBOL you send data to the printer by writing data to a file. In COBOL, the printer is defined as a file, and it is opened, closed, and written to as though it were a file. Like any file, the printer file requires both a logical and a physical definition. 2

3 Printing 3

4 A normal disk file is assigned to a filename on the disk. A printer file is assigned to the COBOL reserved word PRINTER. the ORGANIZATION for the printer file is changed to LINE SEQUENTIAL. A line sequential file is similar to a sequential file, but it usually has carriage return and line feed characters added to the end of each record These are added automatically every time a record is written. This format is suitable for printing or displaying. 4

5 Printing The format also is suitable for a file that is to be edited using a text editor. In fact, the source code files that you are editing whenever you write a program are line sequential files. In this case, the printer file is organized as a line sequential file because a carriage return and line feed are "added" at the end of each line and are sent to the printer to cause the print head to return to the left margin (carriage return) and drop down one line (line feed). 5

6 Printing ORGANIZATION IS LINE SEQUENTIAL is commonly used in many versions of COBOL for the organization of the printer file, but it is not the only organization. – Others organizations ORGANIZATION IS SEQUENTIAL ORGANIZATION IS PRINTER. 6

7 Printing On larger computers with many users and one or more printers, writing to the printer file actually writes to a temporary file on the disk. When the printer file is closed, the temporary file is passed on to another program that handles the scheduling of the printers. The scheduling program usually is called a spooler or a print queue manager. This program sends the temporary file to the printer. 7

8 Printing A data file uses LABEL RECORDS ARE STANDARD, and a print file uses LABEL RECORDS ARE OMITTED. A printer is a device and does not require labeling (filenames). 8

9 Printing 9

10 Controlling the Printer In addition to printing a string of characters on paper, a COBOL program has to tell the printer when to advance one line down the page. It also might have to tell the printer when to advance to the next page. When a WRITE command is used on a printer file, the command can include instructions to force the printer to advance one or more lines. 10

11 Controlling the Printer The BEFORE ADVANCING phrase causes one or more carriage return and line feed characters to be sent to the printer after the line is printed. The BEFORE ADVANCING and AFTER ADVANCING clauses of the WRITE verb are called carriage control clauses or carriage control information. They control the positioning of the print head before or after a line is printed. 11

12 Controlling the Printer 12

13 Controlling the Printer Refer to the sample program at the sample program folder. The further operation of the printing will be discuss in the lab session. 13


Download ppt "Chapter 8 Printing 1. In COBOL you send data to the printer by writing data to a file. In COBOL, the printer is defined as a file, and it is opened, closed,"

Similar presentations


Ads by Google