;;; loops.pro: to run this script, at the idl prompt type ;;; .run loops ;;; ;;; this is an example of for and if-then-else statements: ;;; define an array filled with 15 random numbers, loop ;;; through and if value < 0.5 then set to zero, otherwise ;;; set to 1.0 ep = 15 m = randomu(seed, ep) print, m for i = 0, ep-1 do begin if (m(i) lt 0.5) then begin m(i) = 0.0 endif else begin m(i) = 1.0 endelse endfor print, m end