next up previous contents
Next: Adding a keyword Up: Lecture -1: A first Previous: Passing information into the   Contents

Adding ``stop''

Edit your hello_world.pro file so it contains

pro hello_world, number_questions
;+
;pro hello_world
;Procedure to print ``Hello world'' to screen then ask 'Anyone there?'
;number_questions  times.
;
;Parameters:  number_questions - integer number of times to ask 'anyone there?'
;Keywords: none
;John Marsham, (01/11/06)
;-

print,'Hello world' ;print the line ''Hello world'' to screen

for i=1,number_questions do begin
 print,'Anyone there?'
endfor

stop; STOPS the program here

end

Again type

.compile hello_world
then
hello_world,3
IDL stops at the stop command
% Stop encountered: HELLO_WORLD        17

Type

help,i
This tells you i is an integer and i=4. Similarly you can execute other commands now, such as
print,i
i=i+1
print,i
etc etc.

NowType

.con
help,i
IDL has continued (.con does this) and exited the procedure, so ``i'' is no longer defined. Using ''stops'' like this is very useful when you want to debug things, or just do a few plots from the command line etc.



lecjm 2008-11-06