FIX: READ Does Not Pause or F6501 Error After CTRL+ZLast reviewed: September 16, 1997Article ID: Q81326 |
4.00 4.01 4.10 5.00 5.10
MS-DOS
kbprg kbbuglist kbfixlist kberrmsg
The information in this article applies to:
SYMPTOMSIn an application compiled with Microsoft FORTRAN, when the user responds to a keyboard READ statement with a CTRL+Z character, subsequent READ statements do not pause for input or the run-time library generates the following message:
run-time error F6501: READ(CON) - end of file encountered CAUSEWhen the user enters a CTRL+Z character to signify the end-of-file (EOF) condition, the run-time library sets an internal variable to indicate that the EOF has occurred. This variable remains set until the application executes a PRINT or WRITE statement. When the READ statement includes the END modifier and the internal EOF variable is set, execution branches immediately to the statement specified in the END modifier. When the READ statement does not include the END modifier and the internal EOF variable is set, the F6501 error occurs.
RESOLUTIONTo address this problem, use the PRINT or WRITE statement to send information to the screen and to reset the internal EOF flag prior to each READ that may receive the CTRL+Z. Using the graphics function OUTTEXT to send output to the screen does not clear the internal EOF flag.
STATUSMicrosoft has confirmed this to be a problem in FORTRAN versions 4.0, 4.01, 4.1, 5.0 and 5.1 for MS-DOS. This problem was corrected in FORTRAN PowerStation, version 1.0.
MORE INFORMATIONThe following code sample demonstrates this problem. If the user enters a CTRL+Z for the first READ statement, the application goes into an infinite loop.
Sample Code #1C Compile options needed: None
INCLUDE 'FGRAPH.FI' INCLUDE 'FGRAPH.FD' CHARACTER*1 CHR10 READ (*, '(A)', END = 20) CHR 20 CALL OUTTEXT('Fill the screen!') READ (*, '(A)', END = 10) CHR PRINT *, CHR ENDThe following code example uses the WRITE statement to clear the internal EOF flag before the application encounters any EOF condition. When the user enters CTRL+Z, the application immediately resets the EOF flag and the each READ statement in the application pauses for input as expected.
Sample Code #2C Compile options needed: None
INCLUDE 'FGRAPH.FI' INCLUDE 'FGRAPH.FD' CHARACTER*1 CHR WRITE (*, *)10 READ (*, '(A)', END = 20) CHR 20 CALL OUTTEXT('WRITES ONE LINE!') READ (*, '(A)', END = 10) CHR PRINT *, CHR END |
Additional reference words: 4.00 4.01 4.10 5.00 5.10 buglist5.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |