Microsoft KB Archive/24212

= File I/O Ignores Formatted Carriage Control =

Article ID: 24212

Article Last Modified on 12/1/2003

-

APPLIES TO


 * Microsoft FORTRAN Compiler 3.2
 * Microsoft FORTRAN Compiler 3.3
 * Microsoft FORTRAN Compiler 3.31
 * Microsoft FORTRAN Compiler 4.0
 * Microsoft FORTRAN Compiler 4.01
 * Microsoft FORTRAN Compiler 4.1
 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.1
 * Microsoft FORTRAN Compiler 4.1
 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.1

-



This article was previously published under Q24212



SUMMARY
When an application sends uses formatted I/O and a FORMAT specifier to send a record to a device, FORTRAN interprets the first character of the record as a carriage-control character, as follows:   Character  Interpretation ---  Blank     Advance one line 0        Advance two lines 1        Advance to top of next page (form feed) +        Do not advance (Prints over previous output) FORTRAN ignores the carriage-control character "1" for screen I/O.

Applications commonly specify carriage control as the first character of the FORMAT specifier. However, when an application sends the output to a disk file (rather than sending the output directly to a device), the application places the literal character into the file and does not place any carriage-control information into the file. If you copy the file to the printer, no carriage control occurs.



MORE INFORMATION
Microsoft FORTRAN recognizes the following list of devices.   Device      Comments ---  AUX         COM1 alias COM1       COM1 port CON        stdout, stdin ERR        stderr LINE       COM1 alias LPT1       stdprn NUL        null device PRN        stdprn Microsoft FORTRAN version 5.1 also recognizes the following devices.   Device      Comments ---  USER        stdout, stdin LPT2       stdprn LPT3       stdprn LPT4       stdprn To use carriage control in text sent to a file, the application must explicitly write the carriage-control characters to the file. The following code example sends a form-feed character directly to a printer, but not to a file.

Sample Code #1
C Compile options needed: None

OPEN(1, FILE = 'PRN') OPEN(2, FILE = 'TEST.DAT') WRITE(1, 10) WRITE(2, 10) 10   FORMAT('1 This follows the 1') END The output to the TEST.DAT file is as follows:

1 This follows the 1

The following code example sends a form-feed character to both the printer and to the file using the CHAR intrinsic function.

Sample Code #2
C Compile options needed: None

OPEN(1, FILE = 'PRN') OPEN(2, FILE = 'TEST.DAT') WRITE(1, 10) CHAR(12) WRITE(2, 20) CHAR(12) 10   FORMAT(1X, A, 'This follows the form feed') 20   FORMAT(A, 'This follows the form feed') END Note that the code uses a 1X format character to skip the carriage control field for output sent to the printer. Otherwise, the CHAR(12) character would be interpreted as a blank carriage-control character. In the output to the file, this step is not required because the CHAR(12) is desired in the file as a form-feed character.

In list-directed I/O (the "*" format), the first character of a record is not interpreted as a carriage-control character.

Additional query words: kbinf 3.20 3.30 3.31 4.00 4.01 4.10 5.00 nofps 5.10

Keywords: KB24212

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.