comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Two new tools
items: Re: Two new tools

Two new tools
type: item
description: Howdy, today I finally got around improving my concept of displaying help information on self-written (and library!) routines. Please find attached function routine_name.pro - which returns the name of the caller routine and procedure usage.pro - which displays the "user-relevant" portion of the IDL program header (with minor modifications). The idea of these routines is to prevent wrist injury from too much double typing in constructs like: if (keyword_set(help)) then begin print ; all the stuff that's in the header anyway endif Now, what you can do is: if (keyword_set(help)) then usage,routine_name() and you will get a significant portion from the program header [at least if your routine is stored in a file with the same name]. You can also use usage to get help from the command line: usage,'my_routine_with_too_many_parameters' Hope you'll find this useful, Martin. -- ------------------------------------------------------------ ------- Dr. Martin Schultz Department for Earth&Planetary Sciences, Harvard University 186 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA phone: (617)-496-8318 fax : (617)-495-4551 e-mail: mgs@io.harvard.edu IDL-homepage: http://www-as.harvard.edu/people/staff/mgs/idl/ ------------------------------------------------------------ ------- ;----------------------------------------------------------- -- ;+ ; NAME: ; ROUTINE_NAME (function) ; ; PURPOSE: ; return the name of the routine which calls this function. ; ; CATEGORY ; Tools ; ; CALLING SEQUENCE: ; rname = ROUTINE_NAME() ; ; INPUTS: ; none ; ; KEYWORD PARAMETERS: ; none ; ; OUTPUTS: ; The name of the caller routine is returned in lowercase ; characters (can be used to construct a filename by adding ; ".pro") ; ; SUBROUTINES: ; ; REQUIREMENTS: ; ; NOTES: ; ; EXAMPLE: ; From the command line: ; print,routine_name() ; results in $main$ ; ; Very useful in conjunction with USAGE.PRO: ; usage,routine_name() ; displays help information on the current routine. ; ; MODIFICATION HISTORY: ; m…
creator: Martin Schultz
date: 1998-03-27T08:00:00-00:00

Re: Two new tools
type: item
description: Martin Schultz wrote: Howdy, &nbsp;&nbsp;&nbsp; today I finally got around improving my concept of displaying help information on self-written (and library!) routines. Please find attached &nbsp;&nbsp;&nbsp;&nbsp; function routine_name.pro - which returns the name of the caller routine &nbsp; Hi Martin, this function is in Ray Sterners lib too and will be called with whocalledme,dir,file. IDL> whocalledme,/help &nbsp;Returns to calling routine its parent's directory and name. &nbsp;whocalledme, dir, file &nbsp;&nbsp; dir = Source directory of parent routine.&nbsp;&nbsp; out &nbsp;&nbsp; file = name of parent routine.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&a mp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&a mp;nbsp;&nbsp; out &nbsp;Keywords: &nbsp;&nbsp; LINE=n&nbsp; Line number just after parent's last call. &nbsp;Notes: It can be useful for a routine to know &nbsp;&nbsp; what routine called it. &nbsp;&nbsp; See also: whoami. IDL> whoami,/help &nbsp;Returns to the calling routine its directory and name. &nbsp;whoami, dir, file &nbsp;&nbsp; dir = Source directory of calling routine.&nbsp;&nbsp; out &nbsp;&nbsp; file = name of calling routine.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&a mp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&a mp;nbsp;&nbsp; out &nbsp;Notes: It can be useful for a routine to know &nbsp;&nbsp; what directory it is located in.&nbsp; This allows &nbsp;&nbsp; it to reference auxiliary files in the same &nbsp;&nbsp; directory without needed any special environmental &nbsp;&nbsp; variables defined.&nbsp; The file name returned here is &nbsp;&nbsp; less important since it could always be hardwired &nbsp;&nbsp; into the calling routine itself, but this technique &nbsp;&nbsp; allows this to be avoided for more reusable code. Reimar --&nbsp; R.Bauer&nbsp; Institut fuer Stratosphaerische Chemie (ICG-1) Forschungszentrum Juelich email: R.Bauer@fz-juelich.de &nbsp;
creator: R. Bauer
date: 1998-04-05T08:00:00-00:00