dvbbs
收藏本页
联系我们
论坛帮助
dvbbs

>> Fortran语言使用经验交流
搜一搜相关精彩主题 
Fortran中文网Fortran中文网—Fortran语言经验交流Fortran语言使用经验交流 → [求助]how to read “enter” key in fortran

您是本帖的第 2735 个阅读者
树形 打印
标题:
[求助]how to read “enter” key in fortran
elfsummer
美女呀,离线,留言给我吧!
等级:新手上路
文章:3
积分:266
门派:无门无派
注册:2014年6月26日
楼主
 用支付宝给elfsummer付款或购买其商品,支付宝交易免手续费、安全、快捷! 点击这里发送电子邮件给elfsummer

发贴心情
[求助]how to read “enter” key in fortran
The following fortran 90 program can read in a text file and then print it out on the screen. It has an added feature that when the output covers the whole screen it will pause and wait for the user to press enter key to continue. Currently I use the "PAUSE" to implement this feature. But I would like to know the direct way of reading in the enter key. Please do offer your wisdom. I appreciate it!


program ex0905
implicit none
character(len=79) :: filename
character(len=79) :: buffer
integer, parameter :: fileid = 10
integer :: status = 0,count=0
logical alive
character(len=1) :: c

write(*,*) "Filename:"
read (*,"(A79)") filename
inquire( file=filename, exist=alive)

if ( alive ) then
open(unit=fileid, file=filename, &
access="sequential", status="old")
do while(.true.)
read(unit=fileid, fmt="(A79)", iostat=status ) buffer
if ( status/=0 ) exit
!write(*,"(A79)") buffer
count = count+1
if (count<24) then
write(*,"(A79)") buffer
else
!write(*,*) "Please type Enter to continue: "
pause
count=0
!read(*,"(A1)") c
!if (c==char(13)) then
! write(*,"(A79)") buffer
!else
! write(*,*) "This is not the 'Enter' key!!"
! exit
!end if
end if

end do
else
write(*,*) TRIM(filename)," doesn't exist."
end if

stop
end
[Sorry for typing English =,=]
[此贴子已经被作者于2014-6-27 4:33:06编辑过]
ip地址已设置保密
2014/6/27 4:32:27

 1   1   1/1页      1    
网上贸易 创造奇迹! 阿里巴巴 Alibaba
Powered By Dvbbs Version 7.1.0 Sp1
Copyright ©2005 - 2008 www.fortran.cn
页面执行时间 0.12500 秒, 5 次数据查询
京ICP备05056801号