next up previous contents
Next: The FOR loop Up: Flow Control Previous: The IF statement   Contents

Conditional blocks

If you want statement 1 and / or statement 2 to consist of more than one statement, then:

if  condition then begin
  print, 'statement 1a'
  print, 'statement 1b'
  print, 'statement 1c'
endif

if  condition then begin
  print, 'statement 1a'
  print, 'statement 1b'
  print, 'statement 1c'
endif else begin
  print, 'statement 2a'
  print, 'statement 2b'
  print, 'statement 2c'
endelse

The statements between a begin and an end are called a block of statements.

Blocks of statements can only be used within programs/functions/procedures, and cannot be used at the IDL prompt line.



John Marsham 2009-12-07