[问题] 读档特定区域一问

楼主: bestman8556 (廷廷)   2012-11-19 17:24:13
这是我的data长样:
2012/xx/xx abcdefgxxxxxxxxxxx(表示有问字叙述)
abcdefgxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
12 1234 4567
55 4321 7654
.. .... ....
.. .... ....
.. .... ....
^^^ ^^ ^^
档案中"^"表示有空白的存在
目前已经试过下列方法:
open(unit=10, file='filename.txt')
100 format(2/,5X,I6)
200 format(I6)
read(10,100) a
write(*,200) a
程式码中黄色的2字可以成功跳过2012/xx/xx以及文字叙述那两列
但因为某些需求黄色文字的部分想要用一个变量取代
就像是
E=12
100 format(E/,5X,I6)
但执行结果他都要求我必须以一个constant or general expreesion
来表示我大写E的部分
请求解...............QQ
PS:我有试过另一个方法用open(access='direct',recl=?)
问号的部分我不知道到底要用什么长度分才正确..........
作者: hiyiyi   2011-01-19 17:52:00
1.write(fmtstr,*) E,'/,5X,I6' & read(10,fmtstr) a或2.循环跳行 do i=1,E & read(10,"(A)") linestr & end do
楼主: bestman8556 (廷廷)   2011-01-19 18:44:00
h大的第一种方法是说用write(字串格式,*) E,'/,5X,I6' 来拼凑出一个字串然后写入100 format() 里面吗? 我一值尝试不成功在写出write(字串格式,*) E,'/,5X,I6' 这部分出问题.解决了~~~ 谢谢~~~~

Links booklink

Contact Us: admin [ a t ] ucptt.com