Open a specifiedfile for input/output:
OPENU, unit, filename
OPENW, unit, filename
filename The name of the file to be opened.
Delete If present, causes the file to be deleted when it is closed.
CAUTION: Delete will cause the file to be deleted even if it was opened for read-only access. In addition, once a file is opened with this keyword, there is no way to cancel its operation.
The OPEN procedures always return to the caller without generating an error message when Error is present. A nonzero error status indicates that an error occurred. The error message can then be found in the system variable !Err_String.
For example, statements similar to the following can be used to detect errors:
OPENR, 1, 'demo.dat', Error=err
IF (err NE 0) then PRINTF, -2, !Err_String
GET_LUN, unit OPENR, unit, 'data.dat'
OPENR, unit, 'data.dat', /Get_Lun
Width Specifies the desired width for output. If this keyword is not present, PV-WAVE uses the following rules to determine where to break lines:
Using this keyword makes binary data portable across different machine architectures by reading and writing all data in a standard format. When a file is open for XDR access, the only I/O data transfer procedures that can be used with it are READU and WRITEU.
head.img
file for reading. This file is in the subdirectory data
, under the main PV-WAVE distribution directory. The image is read from the file, and the file is closed.
OPENR, unit, FILEPATH('head.img', $
Subdir = 'data'), /Get_Lun
; Open head.img for reading.
ct = BYTARR(512, 512)
; Create a 256-by-256 byte array to hold the image.
READU, unit, ct
; Read the image.
FREE_LUN, unit
; Close head.img and free the file unit number associated with it.
TVSCL, ct
System Variables: !Err, !Err_String
For background information, see Chapter 8, Working with Data Files, in the PV-WAVE Programmer's Guide.
For more information on XDR, see External Data Representation (XDR) Files in Chapter 8 of the PV-WAVE Programmer's Guide.