Home » IDL » IDL and include

IDL and include

If you want to include another file in an IDL routine, you can of course do this with the ‘@’ symbol as explained by Coyote’s Guide to IDL Programming, i.e. you can have a file a.pro with e.g.

a=1

and a file b.pro with, e.g.,

pro b
@a
print,a
end

This works fine as long as you are always in the same directory. It will, however, not compile if your working directory is not the one in which a.pro and b.pro are. Of course you can modify b.pro to read @/absolute/path/to/a. But a more flexible solution to this that makes it easier to give your code to someone else is to use an environment variable and write @$IDLCODE/demo/a.