作者BrianCashman (最强⑨番-さるの)
看板Fortran
标题Re: [问题] 想请教Fortran如何撰写进度条的语法
时间Mon Aug 17 16:42:03 2009
※ 引述《BrianCashman (最强⑨番-さるの)》之铭言:
: 请先说明你程式是否有GUI,有的话,程式若是非messages polling的方式,基本上画面
: 在进入回圈後会当在那不会更新,只要避免messages不被漏掉,问题不大。
: 基本的进度计算很简单,就是现在回圈指数除以总回圈数乘以100取整数(非四舍五入),
: 於每次回圈计算的最後更新进度值,并最後在回圈外补上100%。
: 若是要计算所需时间,则请加上测量每次或者每几(10 or 100)次回圈所需的时间,
: 平均後(可用移动平均法)乘以剩下回圈数之比例,就是时间剩余评估量。
: 若显示是console text mode,在每次write or print後不要换行,每次都用TL控制码
: 回复列头位置,动起来就会像是你所需要的。
再看一遍文章,发现可能没说清楚,举个实例好了
program Processbar
use ifwin
implicit none
integer total_t,t,process,i
integer whnd
logical ret
character*50 ::barstr
Type(T_COORD) pos
whnd = GetStdHandle(STD_OUTPUT_HANDLE)
pos.x=0
pos.y=0
total_t=36000
do t=1,total_t
process=int(real(t,8)/real(total_t,8)*100)
do i=1,50
if (i <= process/2) then
barstr(i:i)="*"
else
barstr(i:i)="="
end if
end do
ret=SetConsoleCursorPosition(whnd, pos)
write(*,10) process,barstr
10 format (10x,i3,'%',3x,a50)
end do
write(*,*) 'done'
pause
end program Processbar
complier 是 ivfortran , IDE为 VS200X
理论上是visual fortran都没问题
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.171.91.196