Re: library help -- multiple procedures in one file [message #30936] |
Fri, 24 May 2002 13:41 |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
"Liam E. Gumley" wrote:
>
> Craig Markwardt wrote:
> [stuff deleted]
>> By the way I agree with David's suggestions. I am not sure David's
>> are totally compatibile with Liam's recommendations, for example I
>> would say that internal "utility" routines always belong in the main
>> command file, whereas Liam suggests each file has one procedure or
>> function.
>
> That's why I included a caveat in my list of suggestions. For an
> example, my IMDISP image display procedure
>
> http://www.gumley.com/PIP/Free_Software.html
>
> contains several routines that are designed to be called *only* by the
> IMDISP main procedure, and are therefore stored in the IMDISP source
> file. The same would hold true for methods associated with an object.
>
> Cheers,
> Liam.
> Practical IDL Programming
> http://www.gumley.com/
Hi Liam,
We should not forget to use a name conventions if we put
more than one routine in a file.
If we don't there are a lot of conflicts possible.
The routine itselfs is imdisp and all "included" routines
start by imdisp
imdisp is a good example to show this
IMDISP_GETPOS, IMDISP_IMSCALE, IMDISP_IMREGRID, IMDISP_IMSIZE
David mentioned following situation and I aggree to this.
If now for example IMDISP_IMSIZE is so popular to be used alone
or it is useful for an other package it has to be extracted
from this file and then it is a new routine may be "imsize"
in it's own file.
regards
Reimar
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
============================================================ =======
|
|
|
Re: library help -- multiple procedures in one file [message #30937 is a reply to message #30936] |
Fri, 24 May 2002 13:31  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
David Fanning wrote:
>
> Reimar Bauer (r.bauer@fz-juelich.de) writes:
>
>> David, didn't we already talked about this in April
>> by a request of Pepijn Kenter?
>
> Probably. I always seem to be going on about it, for
> all the good it does. :-)
>
>> Who manages the FAQ now ?
>
> No one, AFAIK. Are you volunteering? :-)
We should discuss this after my summer holidays.
At the moment this is to much for me.
Reimar
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
============================================================ =======
|
|
|
Re: library help -- multiple procedures in one file [message #30940 is a reply to message #30937] |
Fri, 24 May 2002 13:16  |
Liam E. Gumley
Messages: 378 Registered: January 2000
|
Senior Member |
|
|
Craig Markwardt wrote:
[stuff deleted]
> By the way I agree with David's suggestions. I am not sure David's
> are totally compatibile with Liam's recommendations, for example I
> would say that internal "utility" routines always belong in the main
> command file, whereas Liam suggests each file has one procedure or
> function.
That's why I included a caveat in my list of suggestions. For an
example, my IMDISP image display procedure
http://www.gumley.com/PIP/Free_Software.html
contains several routines that are designed to be called *only* by the
IMDISP main procedure, and are therefore stored in the IMDISP source
file. The same would hold true for methods associated with an object.
Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
|
|
|
|
Re: library help -- multiple procedures in one file [message #30944 is a reply to message #30942] |
Fri, 24 May 2002 11:36  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
Chris O'Dell <odell@cmb.physics.wisc.edu> writes:
> This question is mostly aimed at people who build libraries for public
> use (David, Craig, etc). I am putting together a lot of the little
> useful routines I have written as a grad student into a library, and was
> wondering, should I juse make EVERY procedure/function have its own
> file? In PASCAL, I was a big proponent of nested functions;
> functions/procedures really ONLY used by one other procedure or
> function. But in IDL, those functions aren't compiled on the fly and
> you have to open the darn function file and compile them all every time
> you start idlde. Is there any way around this?
Hi Chris--
I actually asked the newsgroup this very question about a year ago.
In fact it was related to the "SAVE" library that I published and
(unfortunately) has achieved some infamy.
I had a library with many many functions, each in a separate file, and
I wondered how to manage them all. I felt it would be unwieldy for
the user to have a bunch of files, especially for the routines that
were more or less "internal." I finally decided to restructure the
library so that most of the internal functions were subsumed into more
generalized procedures. Utility routines that were used by only one
procedure were moved into that procedure's file. For the most part I
think that was a good approach.
By the way I agree with David's suggestions. I am not sure David's
are totally compatibile with Liam's recommendations, for example I
would say that internal "utility" routines always belong in the main
command file, whereas Liam suggests each file has one procedure or
function.
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|
Re: library help -- multiple procedures in one file [message #30945 is a reply to message #30944] |
Fri, 24 May 2002 11:29  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
David Fanning wrote:
>
> David Fanning (david@dfanning.com) writes:
>
>> And by the way (since I'm already in a harping
>> sort of a mood) >>>>>>>>> is is <<<<<<<<<< a *great* idea to give
> and
>
>> be >>>>>>>>>>>>> save <<<<<<<<<<< for IDL programmers.
>
> My gosh, I'm in such a bad mood (I'm cleaning the house
> in preparation for the big graduation party tomorrow) that
> even my fingers have decided to leave me alone and have
> run off and started typing on their own. :-(
>
> Cheers,
>
> David
Hi,
David, didn't we already talked about this in April
by a request of Pepijn Kenter?
Who manages the FAQ now ?
Cheers
Reimar
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
============================================================ =======
|
|
|
Re: library help -- multiple procedures in one file [message #30948 is a reply to message #30945] |
Fri, 24 May 2002 11:04  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
"Liam E. Gumley" wrote:
>
> Chris O'Dell wrote:
>>
>> This question is mostly aimed at people who build libraries for public
>> use (David, Craig, etc). I am putting together a lot of the little
>> useful routines I have written as a grad student into a library, and was
>> wondering, should I juse make EVERY procedure/function have its own
>> file? In PASCAL, I was a big proponent of nested functions;
>> functions/procedures really ONLY used by one other procedure or
>> function. But in IDL, those functions aren't compiled on the fly and
>> you have to open the darn function file and compile them all every time
>> you start idlde. Is there any way around this?
>>
>> Cheers,
>> Chris
>
> My preferences:
>
> - One function or procedure per source file,
> - All lower case file names,
> - UNIX formatting (CR/LF) for newlines,
> - Compressed tar files for UNIX users,
> - ZIP files for Win/Mac users,
> - Available via HTTP.
>
> The only exception to the one function or procedure per file rule would
> be if you have several tightly coupled routines that naturally belong
> together, such as the definition of an object and it's methods.
>
I will add normally tar.gz files could be used by windows users
or on the other hand zip on unix systems too.
So it is better to store them in only one type.
If you work with a library some or many of the routines are
using some other routines.
I decided for a few years to be able to make packages for
each routine which might be intersting to someone. Because
someone may like to do a peak into something and sometimes
it's complicated to download a whole library and then to
implement this in an existing library.
Because normally basic things got same names but differnt functionality.
e.g. colorbar
We designed a routine which founds all dependencies of a given routine.
All routines used by one routine are stored into a tar.gz file.
;
; PURPOSE:
; This procedure founds all dependent routines from a given routine.
They are saved into a tar.gz file
; Additional Informations about the routines are saved into an html
file.
;
If you often change pathes of routines have a look on the /refresh
keyword!
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/download/tar_gz_dependencies.tar.gz
The path where you have extracted these file must be set into !PATH e.g.
!PATH=!PATH+':'+'/idl/targz'
because this routine changes the path during executing.
If you like you cn do a peak in our library
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/idl_work_libraries.htm
or on the database of
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/tar_gz_dependencies_dbase.pro.html
If you have binaries of the routines they can be called by idl -rt=file
For example take a peak at x_digisym
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/download/x_digisym.sav
regards
Reimar
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
============================================================ =======
|
|
|
Re: library help -- multiple procedures in one file [message #30949 is a reply to message #30948] |
Fri, 24 May 2002 11:09  |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
Chris O'Dell wrote:
>
> This question is mostly aimed at people who build libraries for public
> use (David, Craig, etc). I am putting together a lot of the little
> useful routines I have written as a grad student into a library, and was
> wondering, should I juse make EVERY procedure/function have its own
> file? In PASCAL, I was a big proponent of nested functions;
> functions/procedures really ONLY used by one other procedure or
> function. But in IDL, those functions aren't compiled on the fly and
> you have to open the darn function file and compile them all every time
> you start idlde. Is there any way around this?
FWIW, I do it the way both Liam and David recommend. Every function procedure in it's own
file. The only time I have more than one function procedure in a file (as far as I can
recall) is for widget code (all the event handlers and what not are listed first) and for
object code (the few, well....one, I have written). And even so, for the widget stuff at
least, you can still have separate files for the event handlers and whatever else is
required. I did that once for a particularly obtuse widget program I wrote (back when it
was still a novelty to do that stuff).
I never use .compile (or whatever) unless I'm actively modifying the file during
development.
paulv
--
Paul van Delst Religious and cultural
CIMSS @ NOAA/NCEP/EMC purity is a fundamentalist
Ph: (301)763-8000 x7274 fantasy
Fax:(301)763-8545 V.S.Naipaul
|
|
|
Re: library help -- multiple procedures in one file [message #30950 is a reply to message #30948] |
Fri, 24 May 2002 11:11  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning (david@dfanning.com) writes:
> And by the way (since I'm already in a harping
> sort of a mood) >>>>>>>>> is is <<<<<<<<<< a *great* idea to give
and
> be >>>>>>>>>>>>> save <<<<<<<<<<< for IDL programmers.
My gosh, I'm in such a bad mood (I'm cleaning the house
in preparation for the big graduation party tomorrow) that
even my fingers have decided to leave me alone and have
run off and started typing on their own. :-(
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
|
|
|
Re: library help -- multiple procedures in one file [message #30951 is a reply to message #30948] |
Fri, 24 May 2002 11:06  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning (david@dfanning.com) writes:
> And it is OK to have many procedures and
> functions that are used only once. Just put them in a
> file _in front of_ the module that has the same name
> as the file. The procedures and functions will be
> utility routines for the "command" module. (The command
> module is always the LAST module in the file and
> has the same name as the file itself.)
And by the way (since I'm already in a harping
sort of a mood) is is a *great* idea to give
these utility routines names my "MyGreatProgram_Print"
and "MyGreatProgram_Save", rather than "Print" and "Save"
unless you enjoy spending late evenings and weekends
tracking down why your programs don't run on your
boss's computer. :-)
Cheers,
David
P.S. Let's just say that if we could only run
one program at a time, the whole world would
be save for IDL programmers.
--
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
|
|
|
Re: library help -- multiple procedures in one file [message #30952 is a reply to message #30948] |
Fri, 24 May 2002 10:23  |
K. Bowman
Messages: 330 Registered: May 2000
|
Senior Member |
|
|
In article <MPG.17581a555d60c0c89898f4@news.frii.com>,
David Fanning <david@dfanning.com> wrote:
> functions that are used only once. Just put them in a
> file _in front of_ the module that has the same name
> as the file.
This has to be one of the most common gotcha's in IDL behavior.
I suppose there might be cases of forgotten code after a named routine,
but is there any reason why RSI couldn't change this the beahvior to
"compile the entire file", rather than "stop after compiling
the program unit whose name matches the file"?
Would this really break anything?
Ken
|
|
|
Re: library help -- multiple procedures in one file [message #30954 is a reply to message #30952] |
Fri, 24 May 2002 10:09  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Liam E. Gumley (Liam.Gumley@ssec.wisc.edu) writes:
> I have to say that I manually compile procedures or functions all the
> time during development and testing, e.g.
>
> 1) Open a source file in nedit (or emacs, vi, IDLDE etc.),
> 2) Make changes to the file and save it,
> 3) Recompile the procedure or function (using .compile),
> 4) Run a test,
> 5) Go back to step 2 and iterate until it runs correctly.
>
> So it's probably more accurate to say that once you are finished
> modifying a source file, and you've placed it in the IDL path, there
> should never be a reason to compile it manually.
Oh, I just hit the button that saves it and compiles it
automatically. I guess I'd forgotten I *ever* compile
routines. :-)
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
|
|
|
Re: library help -- multiple procedures in one file [message #30955 is a reply to message #30954] |
Fri, 24 May 2002 09:50  |
Liam E. Gumley
Messages: 378 Registered: January 2000
|
Senior Member |
|
|
David Fanning wrote:
>
> Chris O'Dell (odell@cmb.physics.wisc.edu) writes:
>
>> This question is mostly aimed at people who build libraries for public
>> use (David, Craig, etc). I am putting together a lot of the little
>> useful routines I have written as a grad student into a library, and was
>> wondering, should I juse make EVERY procedure/function have its own
>> file? In PASCAL, I was a big proponent of nested functions;
>> functions/procedures really ONLY used by one other procedure or
>> function. But in IDL, those functions aren't compiled on the fly and
>> you have to open the darn function file and compile them all every time
>> you start idlde. Is there any way around this?
>
> There should never be any reason to manually compile a file in IDL.
[stuff deleted]
I have to say that I manually compile procedures or functions all the
time during development and testing, e.g.
1) Open a source file in nedit (or emacs, vi, IDLDE etc.),
2) Make changes to the file and save it,
3) Recompile the procedure or function (using .compile),
4) Run a test,
5) Go back to step 2 and iterate until it runs correctly.
So it's probably more accurate to say that once you are finished
modifying a source file, and you've placed it in the IDL path, there
should never be a reason to compile it manually.
Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
|
|
|
Re: library help -- multiple procedures in one file [message #30957 is a reply to message #30955] |
Fri, 24 May 2002 09:37  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Chris O'Dell (odell@cmb.physics.wisc.edu) writes:
> This question is mostly aimed at people who build libraries for public
> use (David, Craig, etc). I am putting together a lot of the little
> useful routines I have written as a grad student into a library, and was
> wondering, should I juse make EVERY procedure/function have its own
> file? In PASCAL, I was a big proponent of nested functions;
> functions/procedures really ONLY used by one other procedure or
> function. But in IDL, those functions aren't compiled on the fly and
> you have to open the darn function file and compile them all every time
> you start idlde. Is there any way around this?
There should never be any reason to manually compile
a file in IDL. And it is OK to have many procedures and
functions that are used only once. Just put them in a
file _in front of_ the module that has the same name
as the file. The procedures and functions will be
utility routines for the "command" module. (The command
module is always the LAST module in the file and
has the same name as the file itself.)
If you think in terms of "commands" that you are building.
Then you will have as many files in your library as you
have commands that you want people to know about and use.
Sometimes utility routines become more useful than you
thought they would become, and they want to be used by
some "other" command. Then, you take that utility module
out of the file it is in, put it in a file of its own,
give it the "command" name, and you now have another
command that everyone can use.
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
|
|
|
Re: library help -- multiple procedures in one file [message #30958 is a reply to message #30957] |
Fri, 24 May 2002 09:16  |
Liam E. Gumley
Messages: 378 Registered: January 2000
|
Senior Member |
|
|
Chris O'Dell wrote:
>
> This question is mostly aimed at people who build libraries for public
> use (David, Craig, etc). I am putting together a lot of the little
> useful routines I have written as a grad student into a library, and was
> wondering, should I juse make EVERY procedure/function have its own
> file? In PASCAL, I was a big proponent of nested functions;
> functions/procedures really ONLY used by one other procedure or
> function. But in IDL, those functions aren't compiled on the fly and
> you have to open the darn function file and compile them all every time
> you start idlde. Is there any way around this?
>
> Cheers,
> Chris
My preferences:
- One function or procedure per source file,
- All lower case file names,
- UNIX formatting (CR/LF) for newlines,
- Compressed tar files for UNIX users,
- ZIP files for Win/Mac users,
- Available via HTTP.
The only exception to the one function or procedure per file rule would
be if you have several tightly coupled routines that naturally belong
together, such as the definition of an object and it's methods.
Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
|
|
|