Assigning Device Names

You can write a COBOL program to send a report directly to the printer or to transfer data across a communications port. To do this, you need to assign a device-name to your COBOL filename.

You can specify the following device-names using static, dynamic or external filename assignment:
Device-name Description
CON Console keyboard or screen
PRN First parallel printer
LPT1 First parallel printer
LPT2 Second parallel printer
LPT3 Third parallel printer
COM1 First asynchronous communications port
COM2 Second asynchronous communications port

When specifying any of these device-names, a trailing colon(:) is optional.

In the following example, read or write operations on fd-name cause data to be read from or written to the console screen:

select fd-name
   assign to "con".

In the next example, write operations on fd-name cause data to be output to lpt1:, the first parallel printer:

select fd-name
   assign to dynamic ws-filename.
   move "lpt1:" to ws-filename.