Re: One file for each procedure/function? [message #30338 is a reply to message #30336] |
Fri, 19 April 2002 06:19   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Pepijn Kenter wrote:
> I'm currently writing analyses software (small programs plus routines) for
> an ozon measurement device and I'm new to IDL. A lot of the routines and
> programs have already been written and are ready for me to use. These
> routines have been grouped together in a few .pro files. These files are
> then compiled explicitly (by .compile statements) in the main programs. The
> programs are called from the command line.
Just to add a bit to Riemar's useful advice, it is useful
to think of a program file as an IDL "command" you
are building. The procedure or function that has the
same name as the command (and the file) should be the last
module in the file. Other procedures and functions that are
used by the command module for its internal use can also be
placed in the file, but always above (in front) of the
command module in the file. In this way, everything is
compiled properly when the "command" is used.
Reimer is correct in recommending that these utility
routines be named starting with a base "command" name.
Otherwise, you have command name chaos and you can never
be sure what procedure or function with this name you
are actually running. For example, naming an event
handler module "Quit" is always a bad idea. The name
"MyProgram_Quit" is much more specific.
Sometimes utility routines take on a life of their own,
and we find them to have wider use than we expected them
to initially. In this case, we take them out of the command
file and place them in a command file of their own, so
they can enjoy wider use by other programs that want to
use them.
It is not unusual to place the programs from an entire
application in separate directories according to
functionality, etc. But typically, these are subdirectories
of an "application" directory that can be added to a user's
Path easily.
By the way, you are correct in thinking that the use
of compile statements goes completely against the
IDL WAY. They are typically used only as a last
resort to sort out command name chaos (see above). :-)
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|