DOCERR: Formatted I/O, Carriage Control, and LPT2

Last reviewed: July 18, 1995
Article ID: Q57572
The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, versions 5.0 and 5.1
  • Microsoft FORTRAN for OS/2, versions 5.0 and 5.1

The section on "Carriage Control" on Page 78 of the "Microsoft FORTRAN Reference" manual for Version 5.0 states the following:

   When formatted I/O is used to transfer a record to a terminal
   device, such as screen or printer, the first character of that
   record is interpreted as a carriage control character, and is not
   printed.

This is not true for printers connected to LPT2. Thus, the carriage control characters listed on Page 79 of the FORTRAN reference manual will not be interpreted properly for the printers connected to LPT2.

The following program is supposed to form feed and then print "5 years". However, it does not form feed and it prints "15 years":

      open (10, file='LPT2', status='OLD')
      write(10,200)
200 format ('15 years')
      end

To get the desired behavior, either change 'LPT2' to 'LPT1' in the OPEN statement and connect the printer to LPT1, or use the CHAR function to send the carriage control characters to the printer on LPT2. The following code sample demonstrates the second workaround:

      open (10, file='LPT2', status='OLD')
      write(10,200) char(12)   ! Form Feed - ASCII 12
200 format (a1,'5 years')
      end


Additional reference words: 5.00 5.10
KBCategory: kbprg kbdocerr
KBSubcategory: FORTLngIss


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 18, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.