Creating a Registered File Reader Routine
For a file reader routine to be available via the IOPEN procedure or the File → Open menu item in the IDL Workbench, it must meet the following criteria:
- It must have the routine signature described below.
- The reader routine's
.profile must be present in a directory included in IDL's !PATH system variable. - It must be added to the
idlextenions.xmlfile as described in Registering Custom File Readers.
See Example: A Workbench NetCDF Reader for an example of a custom file reader routine.
File Reader Routine Signature
A file reader routine should be an IDL function with the following signature:
where:
If you create a file reader routine with this signature and register it in the idlextenions.xml file, IDL will use the routine to open files of the corresponding type when selected using the File → Open menu item in the IDL Workbench or the IOPEN procedure.
Additional Keywords
Although a file reader routine must have exactly one argument — a string containing the name of the file to read — it can include other keywords in addition to the (optional) PALETTE keyword. When using the file reader via the IOPEN routine, any additional keywords specified will be passed from IOPEN to the reader routine using the _EXTRA keyword inheritance mechanism. See Keyword Inheritance in Application Programming for details on the inheritance mechanism.
For example, suppose your file reader includes a METADATA keyword but does not include a PALETTE keyword, giving it a signature that looks like
If the MY_FILE_READER function is placed in a directory in IDL's path, and an entry in the idlextenions.xml file specifies that it should be used to open files with the extension .xyz, then calling IOPEN as follows
would call MY_FILE_READER, placing the retrieved data in a variable named testfile_data and the value returned by the METADATA keyword in a variable named testfile_metadata.
Note
When a file reader is invoked by selecting the File → Open menu item in the IDL Workbench, only the Filename argument and the PALETTE keyword (if present) are used. Other keywords are ignored.