Language > Program Control > Overview of Program Control

# Overview of Program Control

IDL contains various program control constructs for controlling the flow of program execution, such as conditional expressions and looping mechanisms. These constructs include the following.

## Compound Statements

Use BEGIN and END to create a block of statements, which is simply a group of statements that are the subject of a conditional or repetitive statement.

- BEGIN...END

## Conditional Statements

Most useful applications have the ability to perform different actions in response to different conditions. This decision-making ability is provided in the form of conditional statements.

- IF...THEN...ELSE
- CASE
- SWITCH

## Loop Statements

Loop statements perform the same set of statements multiple times. Rather than repeat a set of statements again and again, a loop can be used to perform the same set of statements repeatedly.

- FOR
- FOREACH
- REPEAT...UNTIL
- WHILE...DO

Note: IDL’s array capabilities can often be used in place of loops to write much more efficient programs. For example, if you want to perform the same calculation on each element of an array, you could write a loop to iterate over each array element:
`array = INDGEN(10) FOR i = 0,9 DO BEGIN array[i] = array[i] * 2 ENDFOR`
This is much less efficient than using IDL’s built-in array capabilities:
`array = INDGEN(10) array = array * 2`

## Jump Statements

Jump statements can modify the behavior of conditional and iterative statements.

- BREAK
- CONTINUE
- GOTO