The EXPAND_PATH function is used to expand a simple path-definition string into a full path name for use with the !PATH system variable.

The Path Definition String

EXPAND_PATH accepts a single argument, a scalar string that contains a simple path-definition string, that the function expands into a list of directories that can be assigned to !PATH. This string uses the same format as the IDL_PATH environment variable (Unix, Windows) or logical name (VMS). This format is also used in the path preferences dialog (Windows, Macintosh).

The path-definition string is a scalar string containing a list of directories (and in the case of VMS, text library files that are prefixed with the "@" character), separated by a special character (" : " for Unix and Macintosh, " , " for VMS, and " ; " for Windows). Prepending a "+" character to a directory name causes all of its subdirectories to be searched.

If a directory specified in the string does not have a "+" character prepended to it, it is copied to the output string verbatim. However, if it does have a leading "+" then EXPAND_PATH performs the following steps, searching each subdirectory of the specified directory recursively for other subdirectories. All directories found that contain at least one file of the desired type are added to the search path.

A Note on Order within !PATH

IDL ensures only that all directories containing IDL files are placed in !PATH. The order in which they appear is completely unspecified, and does not necessarily correspond to any specific order (such as top-down alphabetized). This allows IDL to construct the path in the fastest possible way and speeds startup. This is only a problem if two subdirectories in such a hierarchy contain a file with the same name. Such hierarchies usually are a collection of cooperative routines designed to work together, so such duplication is rare.

If the order in which "+" expands directories is a problem for your application, you should add the directories to the path explicitly and not use "+". Only the order of the files within a given "+" entry are determined by IDL. It never reorders !PATH in any other way. You can therefore obtain any search order you desire by writing the path explicitly.

In addition, any text library ( .TLB ) files are added to the result.

Calling Sequence

Result = EXPAND_PATH( String )



A scalar string containing the path-definition string to be expanded. See "The Path Definition String," above, for details.



Set this keyword to return the result as a string array with each element containing one path segment. In this case, there is no need for a separator character and none is supplied. Normally, the result is a string array with the various path segments separated with the correct special delimiter character for the current operating system.


Set this keyword to a named variable which returns the number of path segments contained in the result.


Under the Unix operating system, the default value of !PATH is specified as " +/usr/local/rsi/idl/lib ", unless this default is changed by setting the IDL_PATH environment variable. When IDL starts, one of the first things it does is to run this default value through the EXPAND_PATH function to obtain the actual value for the !PATH system variable. The following statement shows how this expansion might look (assuming that your IDL is installed in /usr/local/rsi/idl ):

PRINT, EXPAND_PATH('+/usr/local/rsi/idl/lib')

IDL prints:


See Also

Executing Program Files and .