Routines (by topic) > Statements

# Statements

## Compound Statements

BEGIN...END - Defines a block of statements.

## Conditional Statements

IF...THEN...ELSE - Conditionally executes a statement or block of statements.

CASE - Selects one statement for execution, depending on the value of an expression.

SWITCH - Selects one statement for execution, depending upon the value of an expression.

## Loop Statements

FOR - Executes one or more statements repeatedly, incrementing or decrementing a variable with each repetition, until a condition is met.

FOREACH- Executes one or more statements for each element of a variable (which can be an array, list, or hash table). Within the FOREACH loop, the element’s value and (optionally) the key or index to which the element corresponds are available.

REPEAT...UNTIL - Repeats statement(s) until expression evaluates to true. Subject is always executed at least once.

WHILE...DO - Performs statement(s) as long as expression evaluates to true. Subject is never executed if condition is initially false.

## Jump Statements

BREAK - Exits from a loop (FOR, WHILE, REPEAT), CASE, or SWITCH statement.

CONTINUE - Starts the next iteration of the enclosing FOR, WHILE, or REPEAT loop.

GOTO - Transfers program control to point specified by label.

## Functions and Procedures

COMPILE_OPT - Gives IDL compiler information that changes the default rules for compiling functions or procedures.

FORWARD_FUNCTION - Causes argument(s) to be interpreted as functions rather than variables (versions of IDL prior to 5.0 used parentheses to declare arrays).

FUNCTION - Defines a function.

PRO - Defines a procedure.

## Variable Scope

COMMON - Creates a common block.