If your function/procedure is called `new' the file should be called new.pro
All the variables you set up within a procedure/function are local (they are defined ''whilst inside the procedure/function''), updates to the parameters, keywords (and the returned result for a function) are passed out to where it was called from
If IDL has a problem and stops within a sub-program, you will find that the variables you can look at or print are those belonging to the sub-program.
You can leave the `scope' of the sub-program and return, or return, value to the main level by typing
IDL> retall ;OR for a procedure: IDL> return ;OR for a function: IDL> return, avalue
Note: passing elements of vectors to procedures e.g.
Function times_two,x ;+ ;pro times_two,x , doubles the value of x. JOHN MARSHAM 22/4/05 ;- x=x*2. endpassing a scalar or a vector:
in=[1.,2.,3.] a=1. print,times_two(a) ;2.00000 - no surprise print,times_two(in) ;2.00000 4.00000 6.00000 - no surpriseBUT passing an elemsnt of a vector or array
in=[1.,2.,3.] print,times_two(in(0)) ; 2.00000 print,in ; 1.00000 2.00000 3.00000 ;DOES NOT UPDATE IN(0)!you have to do
in=[1.,2.,3.] a=in(0) in(0)=times_two(a) print,in ; 2.00000 2.00000 3.00000