Resolving file name character case issues when calling routines
On UNIX, if you save a program file with mixed character cases in the name, such as MyProgram.pro, IDL will issue an error when you call the routine from the IDL command prompt. The error will look like this:
% Attempt to call undefined procedure/function: 'MYPROGRAM'.
% Execution halted at: $MAIN$
This Help Article explains why you encounter this error, discusses the file naming conventions and limitations of various platforms, and describes the proper way to name and call files on UNIX.
UNIX has a case-sensitive file system, while IDL commands are inherently case-insensitive. Although you are free to name a routine with any combination of character cases, IDL will fold all such names to uppercase. Hence, MyProgram is really MYPROGRAM.
During autocompilation of user-written routines on UNIX platforms, IDL converts the routine name to all lowercase characters, and searches for a file with that name. To do otherwise would require IDL to try all combinations of upper and lowercase letters when searching for a file. This would be slow. Also, more than one file with the same name but different combinations of character cases can exist on UNIX. So the intended file for IDL to use would not be obvious.
The proper practice to avoid this problem is to use all lowercase letters when naming a .pro file. This will eliminate confusion and ensure cross-platform code. If you save your program file with all lowercase characters in the name, such as myprogram.pro, IDL will find, compile, and execute the myprogram procedure successfully. Although one can get away with not using all lowercase letters under Microsoft Windows, this is considered to be bad practice because it will cause problems when users try to run the code on UNIX-based platforms.
Platforms and their naming conventions/limitations
Microsoft Windows
- The ":" character is not allowed in a filename.
- File names are case insensitive.
Unix/Linux
- File names are case sensitive -- file.pro is different from File.pro.
- When writing cross-platform applications, you should avoid using filenames that are different only in case.
MacOSX
- As a Unix operating system, Mac OS X files are fully case sensitive.
- This means that the following files are actually distinct and different files.
- MyProcedure.pro
- MYPROCEDURE.pro
- myprocedure.pro
Note:
You can compile and run a program with a mixed- or upper-case file name on a UNIX platform by using IDL’s .COMPILE or .RUN executive commands. However, it is better to always use lower-case file names.
Review on 12/31/2013 MM