IDL Language Elements
The basic language elements of IDL are a bit different from other programming languages such as FORTRAN, C, and C++. These elements include dynamic data types, array operations, positional parameters (arguments), keywords, and automatic compilation. The following sections introduce the basics of these IDL language elements, along with how to avoid naming conflicts.
Variables and Data Types
IDL is different from other languages that require programmers to specifically designate a particular data type for each variable. IDL interprets variable types by their usage. This "loose" or dynamic data typing gives IDL flexibility and the ability to redefine variable data types at the command line or within programs. With this flexibility comes the need to keep track of the data types. IDL's built-in HELP procedure is an easy tool to use to return the data type of any variable, as shown in the following command-line example:
Another example shows how the same variable is redefined as another data type:
Notice that since the variable value is within single quotes, IDL interprets it as a string. IDL does not hold the previous value of the variable in memory, so it can be changed at any time.
The three valid IDL variable organizations are scalars, arrays, and structures:
There are 16 variable types in IDL, which are shown in the following table:
Arguments
Arguments in IDL are positional parameters that pass information to a routine. In other words, each argument must be given in the order specified by the syntax of the routine. Some arguments are required, while others are optional, depending on the routine.
For example, the IDL system routine PLOT has two arguments: x and y. The arguments must be given in the correct order or the resulting plot's axes will be incorrect. If the y argument is not given, the routine plots y as a function of x, as shown in the following example:
The result of this command is the following plot:

Keywords
Keywords are optional parameters that consist of keyword-value pairs. They can be passed to a routine in any order. If a keyword is not specified, the default value of that keyword is passed to the routine. A routine may have many available keywords to choose from. You can use as many or as few as you need.
Continuing with the PLOT example, we adds keywords to label the x and y axes:
IPLOT, EXP(FINDGEN(10)), XTITLE='Time', YTITLE='Velocity'

Automatic Compilation
IDL compiles routines any time it encounters a routine name, whether it is typed at the command line or called from another routine. If the routine is already in IDL's memory, IDL runs it. If the routine is not in memory, IDL searches each directory in the path definition for (filename.pro) and automatically compiles it. (For more on the IDL path, see IDL_PATH.)
Note
IDL routines all have specific names, which can conflict with user-written routines if those routines have the same name. When IDL encounters this conflict, the automatic compilation mechanism ignores the user-written routine. For more information, see Advice for Library Authors.
Code Written in Other Programming Languages
IDL allows you to incorporate routines written in other programming languages using the following methods:
- Call Java or COM objects and methods using the Import Bridge technology. See IDL Import Bridge for information.
- Call other types of external sharable object code (C or FORTRAN, for example). See the CALL_EXTERNAL, LINKIMAGE, MAKE_DLL routines, and External Development Overview for information.
- You can also export IDL objects for use by Java or COM programs. See IDL Export Bridge for information.