File I/O Ignores Formatted Carriage ControlLast reviewed: July 19, 1995Article ID: Q24212 |
The information in this article applies to:
SUMMARYWhen 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 INFORMATIONMicrosoft 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 stdprnMicrosoft FORTRAN version 5.1 also recognizes the following devices.
Device Comments ------------------------------- USER stdout, stdin LPT2 stdprn LPT3 stdprn LPT4 stdprnTo 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 #1C 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') ENDThe 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 #2C 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') ENDNote 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 reference words: kbinf 3.20 3.30 3.31 4.00 4.01 4.10 5.00 5.10
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |