next up previous contents
Next: Resetting, compiling etc Up: Lecture 1: Getting Started Previous: A First Plot   Contents

Another Program

We can put a list of IDL commands into a file to make a program e.g. dubya.pro

pro dubya,usestop=usestop
;+
;pro dubya
;Procedure to plot dubya's polularity over time as polled by IAS and
;SRI
;No parameters 
;Keywords: setting usestop stops program before the end
;Hugh Pumphrey, Edinburgh (many years ago). Updated: John Marsham,
;Leeds (16/3/05)
;-

; **** Here are the data. ****
x = [1, 2, 4, 5, 6.7, 7, 8, 10 ]    ; time 
y = [40, 30, 10, 20, 53, 20, 10, 5] ; popularity  (IAS polling)
y2 = [30, 28, 8, 19, 50, 22, 12, 6] ; popularity  (SRI polling)


; ****  make a plot of the first set of data ***** 
plot,x,y,title='Should he resign?',xtitle='weeks', $
   ytitle='Popularity', psym=-2	

; --- Note how we use $ in the above command  to continue onto the
; --- next line

; +++++++  Add the second set to the plot +++++++ 
oplot,x,y2,linestyle=2, psym=-6

; stop if usestop keyword is set (i.e. > 0)
if keyword_set(usestop) then stop

; End of the program - don't forget this!
end

The semicolon is a comment

The dollar symbol, $, is a line continuation character

The introduction between the ;+ and ;-. is standard - it's really useful to define all the inputs, outputs, keywords etc here (including units!) You can automatically document all these introductions using

``MK_HTML_HELP''.

Also note the use of ``psym=minus value'' to get a symbol and a line.

It is important that the file name ends in ``.pro'' or IDL may not find it. Also using capitals in the procedure name can cause problems.



lecjm 2008-11-06