2.6.2 Programs, Procedures, and Functions


next up previous contents
Next: 2.6.3 Running IDL programs Up: 2.6 Interactive Data Language Previous: 2.6.1 Some Comments about

2.6.2 Programs, Procedures, and Functions

An IDL main program requires a .RUN command to run, and the code within that file starts executing after successful compilation.

An IDL procedure is a kind of subroutine and has something like
PRO PROCEDURE_NAME, PARAM1, PARAM2
at the top of the file. The variables in the procedure definition can be input or output. It is possible to have keywords with a command like
PRO PROCEDURE_NAME, KEY1=KEY1, KEY2=KEY2
It can be executed with a command like:
IDL> procedure_name, a, b

IDL> procedure_name, a, b, key1=c
An IDL function is another kind of subroutine and has something like
FUNCTION FUNCTION_NAME, PARAM1, PARAM2
at the top of the file. The primary output is passed to result but it is possible to have parameters in the call which can receive output. It is executed with a command like:
IDL> result = function_name(a,b)


ydac@mssly1.mssl.ucl.ac.uk