zoukankan      html  css  js  c++  java
  • READF: End of file encountered. Unit: 100

    File contents:

    20.2 22.93

    22.23 26.1

    19.92 23.55

    19.33 24.7

    20.68 24.25

    24.83 29.47

    23.88 29.53

    24.55 29.1

    22.48 27.17

    22.32 27.28

    25.62 30.08

    23.3 28.75

    20.98 24.55

    22.68 28.08

    23.92 26.52

    19.73 24.37

    24.88 29.03

    27.12 32.48

    20.92 26.25

    27.55 33.52

    27.58 35.18

    27.4 31.47

    25.87 30.52

    25 29.5

    example code:

    IDL> print, file_lines('sample1.txt')

    24

    IDL> openr, lun, 'sample1.txt', /get_lun

    IDL> readf, lun, data1

    IDL> print, data1

    20.2000

    IDL> readf, lun, data2

    IDL> print, data2

    22.2300

    IDL> data = fltarr(2,24)

    IDL> readf,lun,data

    % READF: End of file encountered. Unit: 100, File: sample1.txt

    % Execution halted at: $MAIN$

    What happened? Read beyond the end of the file(because we had already read in the first 2 lines)

    IDL> point_lun, lun, 0

    IDL> readf,lun,data

    IDL> print, min(data), max(data)

    ;PRO file

    pro readfile

    file='sample1.txt'

    openr,lun,file, /get_lun

    lines=file_lines(file)

    thislat=fltarr(lines)

    thislon=fltarr(lines)

    temp1=0.0

    temp2=0.0

    point_lun, lun, 0

    ;header=''

    ;readf, lun, header

    FOR j=0, lines-1 DO BEGIN

    readf,lun, temp1, temp2

    thislat[j]=temp1

    thislon[j]=temp2

    ENDFOR

    close,lun

    free_lun, lun

    print, thislat, thislon

    print, 'done!'

    end

    我碰到的这个问题原因是我没有free_lun,lun

    转载注明出处:http://www.cnblogs.com/RSmountain/
  • 相关阅读:
    1083 List Grades (25 分)
    1075 PAT Judge (25 分)
    15. 会话之session
    我的编程路----
    jQuery
    CSS
    HTML display 属性 和 行内元素、块状元素、行内块状元素的区别
    实例1 : 返回顶部小操作(JQ + JS 实现)
    jQuery 事件方法
    为什么静态方法 不可以 被 非静态方法调用?
  • 原文地址:https://www.cnblogs.com/RSmountain/p/2893267.html
Copyright © 2011-2022 走看看