Skip to main content

5.1) Functions And Procedures


So far we have performed some simple mathematics and generated a simple plot putting the IDL code in a file and using the command line, but this isn't a very powerful way of programming.

One key to good programming is to put each component operation in a separate file and you can then re-use that file many times.

We have already used some of the built-in IDL functions such as "mean" and "cos", and procedures such as plot, but IDL allows you to define your own functions and procedures.

We have created a "main" program already, which we ran using ".r", but by using functions and procedures you can pass things into the code in the file, which then passes the answers back out. This makes the code more useful as it is now re-usable.