Article ID: 67098 - Last Review: December 1, 2003 - Revision: 2.0 FIX: PAUSE Command with Input Redirection in FORTRANThis article was previously published under Q67098 On This PageSYMPTOMS
Beginning with Microsoft FORTRAN version 4.0, the PAUSE command allows you
to execute operating system commands while program execution is suspended.
When program input is redirected from the keyboard to a file, the PAUSE
statement does not work correctly if the program READs from the redirection
file or if the program contains multiple PAUSE statements.
STATUS
Microsoft has confirmed this to be a problem in FORTRAN versions 4.x
and 5.0. This problem was corrected in FORTRAN version 5.1.
MORE INFORMATION
When input is redirected from a file and the only data read from the
file is one MS-DOS command for a PAUSE statement, the program works
correctly. The following short program gives an example:
Sample Code
Ver
Output:
1
Before PAUSE
When the READ statement is before the PAUSE statement, the DOS command
is not executed:
Pause - Please enter a blank line (to continue) or a DOS command. MS-DOS Version x.xx After PAUSE run-time error F6501: READ(CON) - end of file encountered Code:
1
Output:
Ver
1
These problems are caused by the PAUSE command not reading data from
the redirection file in the same way a READ statement would.
Before PAUSE Pause - Please enter a blank line (to continue) or a DOS command. After PAUSE WorkaroundsDo not use redirection on a program with more than one PAUSE statement or a combination of PAUSE and READ statements.Use the OPEN command to open a file to be used for input for READ statements. Use calls to the C functions SYSTEM or SPAWNLP instead of PAUSE statements to execute DOS commands. For more information on these functions, see page 86 of the "FORTRAN Advanced Topics" manual for version 5.00 or the DEMOEXEC.FOR program included with versions 4.x and 5.00 of FORTRAN. This problem does not occur in earlier versions of FORTRAN because the functionality of the PAUSE statement is different. In earlier versions, you are not allowed to execute DOS commands after a PAUSE. APPLIES TO
| Article Translations
|

Back to the top
