Files and I/O
IDL's file input and file output routines are designed to work identically on all platforms, where possible. In the case of basic operations, such as opening a text file and reading its contents, importing an image format file into an IDL array, or writing ASCII data to a file on a hard disk, IDL's I/O routines work the same way on all platforms. In more complicated cases, however, such as reading data stored in binary data format files, different operating systems may use files that are structured differently, and extra care may be necessary to ensure that IDL reads or writes files in the proper way.
Before attempting to write a cross-platform IDL application that uses more than basic file I/O, you should read and understand the sections in Files and Input/Output that apply to the platforms your application will support. The following are a few topics to think about when writing IDL applications that do input/output.
Byte Order Issues
Computer systems on which IDL runs support two ways of ordering the bytes that make up an arbitrary scalar: big endian, in which multiple byte numbers are stored in memory beginning with the most significant byte, and little endian, in which numbers are stored beginning with the least significant byte. The following table lists the processor types and operating systems IDL supports and their byte ordering schemes:
The IDL routines BYTEORDER and SWAP_ENDIAN allow you to convert numbers from big endian format to little endian format and vice versa. It is often easier, however, to use the XDR (for eXternal Data Representation) format to store data that you know will be used by multiple platforms. XDR files write binary data in a standard "canonical" representation; as a result, the files are slightly larger than pure binary data files. XDR files can be read and written on any platform that supports IDL. XDR is discussed in detail in Portable Unformatted Input/Output.