read/write to /XDR file? [message #7104] |
Wed, 02 October 1996 00:00 |
Kile_Baker
Messages: 5 Registered: March 1994
|
Junior Member |
|
|
I was sent the following IDL function designed to read an unformatted
data file written in XDR form. Take a look at it and tell me why it works!
----------------------
function read_file,file
openr, unit, /get, file, /xdr
infile=''
filter=''
time=''
n=0
m=0
writeu, unit, infile
writeu, unit, filter
writeu, unit, time
writeu, unit, n, m
image = intarr(n,m)
lat = dblarr(n,m)
lon = dblarr(n,m)
writeu, unit, image
writeu, unit, lat
writeu, unit, lon
free_lun, unit
return, {image: image, lat:lat, lon:lon, infile:infile, $
time:time, filter:filter}
end
--------------------------
No, I didn't make a mistake typing this. The file is opened for READING,
but then the instructions say to WRITE unformatted data to this readonly
file. There are no errors produced, and miraculously, the structure
that is returned contains all the data from the file.
This was done on an HP UNIX system. Does the same thing work on
other systems? How and why?
--
Kile Baker (kile_baker@jhuapl.edu) | All opinions are my own and
Johns Hopkins Applied Phys. Lab | not those of the JHU/APL
|
|
|