Reading in to array elements from a file. [message #12274] |
Wed, 22 July 1998 00:00 |
nrogers
Messages: 1 Registered: July 1998
|
Junior Member |
|
|
I wonder if anyone could solve the following mystery for me.
I am trying to read in *individual* array elements from a file using
the readf procedure. I have an input file called test.txt containing
(say)
1 2 3 4 5 6
and the following IDL procedure to read them in and print them out
again.
;------------------
pro test
array=intarr(6)
infile='test.txt'
openr,inlun,infile,/get_lun
for cnt=0,5 do begin
readf,inlun,array[cnt]
endfor
close,inlun
free_lun,inlun
print,array
return
end
;-----------------
Unfortunately, although no compile or run-time errors are encountered,
nothing is assigned to the array elements and the file pointer stays
at the beginning of the file. The output is then,
0 0 0 0 0 0
Why is this?
Thanks for your help.
Neil.
|
|
|