Previous IDL Reference Guide: Overview of IDL Syntax Next

IDL Syntax

The following table lists the elements used in IDL syntax listings:

Table 1-1: Elements of IDL Syntax

Table 1-1: Elements of IDL Syntax
Element
Description
[ ] (Square brackets)
Indicates that the contents are optional. Do not include the brackets in your call.
[ ] (Italicized square brackets)
Indicates that the square brackets are part of the statement (used to define an array).
Argument
Arguments are shown in italics, and must be specified in the order listed.
KEYWORD
Keywords are all caps, and can be specified in any order. For functions, all arguments and keywords must be contained within parentheses.
/KEYWORD
Indicates a boolean keyword.
Italics
Indicates arguments, expressions, or statements for which you must provide values.
{ } (Braces)
  • Indicates that you must choose one of the values they contain
  •  

  • Encloses a list of possible values, separated by vertical lines ( | )
  •  

  • Encloses useful information about a keyword
  •  

  • Defines an IDL structure (this is the only case in which the braces are included in the call).
| (Vertical lines)
Separates multiple values or keywords.
[, Value1, ... , Valuen]
Indicates that any number of values can be specified.
[, Value1, ... , Value8]
Indicates the maximum number of values that can be specified.

Elements of Syntax

Square Brackets ( [ ] )

Braces ( { } )

Italics

Procedures

IDL procedures use the following general syntax:

PROCEDURE_NAME, Argument [, Optional_Argument]

where PROCEDURE_NAME is the name of the procedure, Argument is a required parameter, and Optional_Argument is an optional parameter to the procedure.

Functions

IDL functions use the following general syntax:

Result = FUNCTION_NAME( Argument [, Optional_Argument] )

where Result is the returned value of the function, FUNCTION_NAME is the name of the function, Argument is a required parameter, and Optional_Argument is an optional parameter. Note that all arguments and keyword arguments to functions should be supplied within the parentheses that follow the function's name.

Functions do not always have to be used in assignment statements (i.e., A=SIN(10.2)), they can be used just like any other IDL expression. For example, you could print the result of SIN(10.2) by entering the command:

PRINT, SIN(10.2)  

Arguments

The "Arguments" section describes each valid argument to the routine. Note that these arguments are positional parameters that must be supplied in the order indicated by the routine's syntax.

Named Variables

Often, arguments that contain values upon return from the function or procedure ("output arguments") are described as accepting "named variables". A named variable is simply a valid IDL variable name. This variable does not need to be defined before being used as an output argument. Note, however that when an argument calls for a named variable, only a named variable can be used—sending an expression causes an error.

Keywords

The "Keywords" section describes each valid keyword argument to the routine. Note that keyword arguments are formal parameters that can be supplied in any order.

Keyword arguments are supplied to IDL routines by including the keyword name followed by an equal sign ("=") and the value to which the keyword should be set. The value can be a value, an expression, or a named variable (a named variable is simply a valid IDL variable name).


Note
If you set a keyword equal to an undefined named variable, IDL will quietly ignore the value.

For example, to produce a plot with diamond-shaped plotting symbols, the PSYM keyword should be set to 4 as follows:

PLOT, FINDGEN(10), PSYM=4  

Note the following when specifying keywords:

  IDL Online Help (March 06, 2007)