OPEN always returns to the caller without generating an error message when ERROR is present. If an error occurs in the attempt to open File, IDL normally takes the error handling action defined by the ON_ERROR and/or ON_IOERROR procedures.
ERRORĪ named variable to place the error status in. In addition, once a file is opened with this keyword, there is no way to cancel its operation. Note: Setting the DELETE keyword causes the file to be deleted even if it was opened for read-only access. Set this keyword to delete the file when it is closed. Tip: The FILE_GZIP/ FILE_GUNZIP and ZLIB_COMPRESS/ ZLIB_UNCOMPRESS routines can also be used to process GZIP files and streams. COMPRESS cannot be used with the APPEND keyword. This means that IDL's compressed files are 100% compatible with the widely available gzip and gunzip programs. IDL's GZIP support is based on the freely available ZLIB library by Mark Adler and Jean-loup Gailly (see for details). If COMPRESS is set, IDL reads and writes all data to the file in the standard GZIP format. Also note that the system stdio may choose to ignore the buffer size setting. Under UNIX, the RAWIO keyword must not be set. Note that the buffer size is only changeable when reading and writing stream files. Setting BUFSIZE=1 (or any other value less than 512) sets the buffer to the default size, which is platform-specific. Set this keyword to a value greater than 512 to specify the size of the I/O buffer (in bytes) used when reading and writing files. The APPEND and COMPRESS keywords are mutually exclusive and cannot be specified together. Under UNIX, use of APPEND prevents OPENW from truncating existing file contents. Normally, the file is opened with the file pointer at the beginning of the file. Set this keyword to open the file with the file pointer at the end of the file, ready for data to be appended. Note: Platform-specific keywords are listed at the end of this section. Note: The optional Record_Length argument is obsolete, and should not be used in new code. However, it is faster not to use wildcards because IDL doesn’t use the shell to expand file names unless it has to. Under UNIX, the filename can contain any wildcard characters recognized by the shell specified by the SHELL environment variable. FileĪ string containing the name of the file to be opened. The unit number to be associated with the opened file. There are three forms of the OPEN procedure: Define a variable into which the image will be read: OPENR, 1, FILEPATH( 'people.dat', SUBDIR = )
#IDL OPENW FULL#
function is used to return the full path name to this
The following example opens the IDL distribution file people.dat and reads an image from that file: Open 'people.dat' on file unit number 1. See Understanding (LUNs) for additional information on LUNs.
#IDL OPENW FREE#
Letting IDL assign the LUN from the list of free unit numbers ensures that your application does not attempt to use a LUN already in use by someone else’s application. By using the GET_LUN keyword to the OPEN routines, you can ask IDL to assign a free Logical Unit Number between 100-128 to the specified file. While it is possible to assign any of the integers between 1-99 to a given file, when writing applications for others it is good programming practice to let IDL assign and manage the LUNs itself. There are a total of 128 LUNs available for assignment to files.
Logical Unit Numbers (LUNs) are assigned to individual files when the files are opened by the IDL OPENR/OPENU/OPENW commands, and are used to specify which file IDL should read from or write to. Logical Unit Numbers and Application Development OPENU (OPEN Update) opens an existing file for input and output.If the file exists, it is truncated and its old contents are destroyed. OPENW (OPEN Write) opens a new file for input and output.OPENR (OPEN Read) opens an existing file for input only.The three OPEN procedures open a specified file for input and/or output.