comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Re: Which like command for IDL?

Re: Which like command for IDL?
type: item
description: Jason P. Meyers (jpm7934@cis.rit.edu) writes: > I was recently working with some examples from Dave Fanning's book > (nice book Dave) when I realized it would be nice to have an IDL program > that works like the unix "which" command. I had typed in the > Display.pro program on page 66 only to find out that there is some other > program (I suspect an RSI demo) also called Display.pro elsewhere on my > IDL path. It would sure be nice to be able to quickly identify which > program IDL is using from the path. > > Does anyone out there know of such a beast for IDL? Try this: IDL> Help, /Source That should do it. :-) Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting Phone: 970-221-0438 E-Mail: davidf@dfanning.com Coyote's Guide to IDL Programming: http://www.dfanning.com/ Toll-Free IDL Book Orders: 1-888-461-0155
creator: davidf
date: 2001-01-05T00:33:54-00:00

Re: Which like command for IDL?
type: item
description: David Fanning wrote: > > Jason P. Meyers (jpm7934@cis.rit.edu) writes: > >> I was recently working with some examples from Dave Fanning's book >> (nice book Dave) when I realized it would be nice to have an IDL program >> that works like the unix "which" command. I had typed in the >> Display.pro program on page 66 only to find out that there is some other >> program (I suspect an RSI demo) also called Display.pro elsewhere on my >> IDL path. It would sure be nice to be able to quickly identify which >> program IDL is using from the path. >> >> Does anyone out there know of such a beast for IDL? > > Try this: > > IDL> Help, /Source > > That does the job for a routine you've already compiled, but what if you want to find out BEFORE you compile it which display.pro you would end up running? Or even better (JD can probably do this with a recursive one-line routine), how about a procedure that goes through your full path and finds all of the duplicate filenames? I've often wanted to do this so that I could do some preemptive file renaming, but I haven't taken on the task yet. I am sure that I have about six different routines called CIRCLE.PRO in libraries that I have gotten from people, and having a routine that figured this out in advance would be a nice thing. I got burned a year ago (UNIX system) by storing old versions of programs in a subdirectory called OLD. It turns out that the !Path was set up in such a way that the procedures in the OLD directory had precedence over the new ones. Took me a long time to figure out why it was that the changes I was putting in my program never got executed! Dick
creator: Richard French
date: 2001-01-05T01:51:53-00:00

Re: Which like command for IDL?
type: item
description: Richard G. French (rfrench@wellesley.edu) writes: > That does the job for a routine you've already compiled, but what if you > want to find out BEFORE you compile it which display.pro you would end > up running? Can't be done. Heisenberg uncertainty principle applies. You can't possibly know WHICH routine you are using until the wave function collapses. Or, was that an electron? Humm. Can't remember ... :-( > Or even better (JD can probably do this with a recursive > one-line routine), how about a procedure that goes through your full > path and finds all of the duplicate filenames? I'm shocked that you think JD can write better recursive functions than me. But I'm busy. I'll leave it to him. :-) > I am sure that I have about six different routines > called CIRCLE.PRO in libraries that I have gotten from people, and > having > a routine that figured this out in advance would be a nice thing. How about this WHICH program. *Very* quick and dirty. I'll leave it to others to make perfect. (I can already think of a couple of ways it can be greatly improved.) But this finds the *first* program with the given name of all the names I tested it on. Of course, it can only find library routines. :-) IDL> Which, "arrow" D:\RSI\IDL54\lib\arrow.pro IDL> Which, "congrid", /Func D:\RSI\IDL54\lib\congrid.pro Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting Phone: 970-221-0438 E-Mail: davidf@dfanning.com Coyote's Guide to IDL Programming: http://www.dfanning.com/ Toll-Free IDL Book Orders: 1-888-461-0155 ************************************************************ ****** PRO WHICH, routineName, Funct=funct Catch, theError IF theError NE 0 THEN BEGIN Catch, /Cancel answer = Dialog_Message("Can't find: " + StrUpCase(routineName) + $ '. Is this a function?', /Question) IF StrUpCase(answer) EQ 'YES' THEN BEGIN Catch, theError IF theError NE 0 THEN BEGIN Catch, /Cancel ok = Dialog_Message("Sorry. Can't find: " + $ StrUpCase(routineName) + '. Returning') RETURN ENDIF Which…
creator: davidf
date: 2001-01-05T02:55:27-00:00

Re: Which like command for IDL?
type: item
description: David Fanning (davidf@dfanning.com) writes: > How about this WHICH program. *Very* quick and dirty. > I'll leave it to others to make perfect. (I can already > think of a couple of ways it can be greatly improved.) Oh, bother! :-( Those guys at RSI have gone and done it again. They have already improved on my wonderful Which wesult. See the FILE_WHICH routine in the IDL 5.4 library, which finds the right file *without* collapsing the wave function. Those guys really take all the fun out of it, don't they. :-( Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting Phone: 970-221-0438 E-Mail: davidf@dfanning.com Coyote's Guide to IDL Programming: http://www.dfanning.com/ Toll-Free IDL Book Orders: 1-888-461-0155
creator: davidf
date: 2001-01-05T03:32:00-00:00

Re: Which like command for IDL?
type: item
description: David Fanning wrote: > > David Fanning (davidf@dfanning.com) writes: > >> How about this WHICH program. *Very* quick and dirty. >> I'll leave it to others to make perfect. (I can already >> think of a couple of ways it can be greatly improved.) > > Oh, bother! :-( > > Those guys at RSI have gone and done it again. They > have already improved on my wonderful Which wesult. > See the FILE_WHICH routine in the IDL 5.4 library, > which finds the right file *without* collapsing > the wave function. > > Those guys really take all the fun out of it, don't > they. :-( Hi David, this brings up an interesting legal/buisiness question: If file_which is an IDL file (.pro) distributed with 5.4 is it then permitted to use this routine with earlier versions of IDL (provided it works)? Legally, I would think this should be doable at least as long as you are under a maintenance contract, i.e. you could theoretically run 5.4 but haven't installed it for whatever reason. Without a current maintenance contract, there would be the question if such a new library routine belongs to IDL5.4 or to IDL in general. Buisineswise, it might be a smart move of RSI to put their library routines under the open source license and post them own their web site. Nobody without a licensed IDL program can use these routines anyway, and it could be regarded as a nice service to the users if they can profit from new developments in the library routines. Just a thought, Martin -- [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[ [[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[ [[ Bundesstr. 55, 20146 Hamburg [[ [[ phone: +49 40 41173-308 [[ [[ fax: +49 40 41173-298 [[ [[ martin.schultz@dkrz.de [[ [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
creator: Martin Schultz
date: 2001-01-05T09:42:32-00:00

Re: Which like command for IDL?
type: item
description: Martin Schultz (martin.schultz@dkrz.de) writes: > this brings up an interesting legal/buisiness question: If > file_which is an IDL file (.pro) distributed with 5.4 is it then > permitted to use this routine with earlier versions of IDL (provided > it works)? I've no idea about this, although I have to imagine that the good folks at RSI have better things to do than run around harassing customers about using RSI-supplied programs written in IDL. :-) It is a moot point anyway, in this case, since the program uses some of the neat new SWITCH, BREAK, etc. stuff that comes in IDL 5.4, and will not compile in earlier versions. Cheers, David P.S. Let's just say for all of you poor relations out there, we have the Coyote library and its crummy WHICH program. :-) -- David Fanning, Ph.D. Fanning Software Consulting Phone: 970-221-0438 E-Mail: davidf@dfanning.com Coyote's Guide to IDL Programming: http://www.dfanning.com/ Toll-Free IDL Book Orders: 1-888-461-0155
creator: davidf
date: 2001-01-05T15:15:06-00:00

Re: Which like command for IDL?
type: item
description: I hate to be a one tune band, but the best way I have of doing this kind of shadow mapping (finding files defining procedures which shadow each other), is with IDLWAVE. Why is this superior to anything offered internally in IDL? For one, it doesn't need IDL! It uses it's own notion of IDL builtins, system library files (the ones in !DIR/lib), and the user catalog it scanned. If IDL is running in the shell, it also queries it for all routine info. Since I've scanned into my catalog almost everything on !PATH (IDLWAVE makes it trivial), I can easily see which files define a procedure. I can even do a full shadow scan of the entire system, or all routines in the current buffer, or all routines compiled in the shell. The most trivial way to see multiple sources, however, is with routine info (which you'll probably be using for other things all the time anyway). For instance, here's the routine info (invoked via [C-c ?] when near a pro/func), for print, which I've unwisely redefined several times: Usage: PRINT [, Expr1, ..., Exprn] Keywords: AM_PM DAYS_OF_WEEK FORMAT MONTHS REWRITE STDIO_NON_FINITE Sources: - Builtin - Other [-SB] ~/foo.pro - Library [C--] ~/idl/scrap/print.pro - Library [C--] ~/idl/scrap/printf.pro We see 4 sources, in order of likelihood of usage. Here, the built-in print is always used. You can't override it. Then we have a file foo.pro in a buffer I'm visiting (the B), which has a version of "print" compiled in the shell (S) (will I never learn). Then there's a pair of "Library" files (which just means they're in !PATH), which have been scanned and put into my catalog "C". What about something you can override? How about one of the !DIR/lib procedures which comes with IDL? Here's an example shadow listing for one of those (notice it's the same as routine info, but without the usage/keyword stuff). ValidateManagedWidgets - SystemLib [C--] /usr/local/rsi/idl/lib/xmanager.pro - Library [C--] ~/idl/scrap/xmanager.pro So, I've redefined ValidateManagedWid…
creator: John-David T. Smith
date: 2001-01-05T15:21:49-00:00

Re: Which like command for IDL?
type: item
description: David Fanning (davidf@dfanning.com) writes: > It is a moot point anyway, in this case, since the program > uses some of the neat new SWITCH, BREAK, etc. stuff that > comes in IDL 5.4, and will not compile in earlier versions. Interestingly, the FILE_WHICH program supplied in IDL 5.4 calls a built-in, but undocumented, program STRTOK, which appears to separate the path subdirectories based on a delimiter supplied to the function. I'll leave it to the expert sleuths in the group to tell us what it *really* does. :-) Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting Phone: 970-221-0438 E-Mail: davidf@dfanning.com Coyote's Guide to IDL Programming: http://www.dfanning.com/ Toll-Free IDL Book Orders: 1-888-461-0155
creator: davidf
date: 2001-01-05T16:06:41-00:00

Re: Which like command for IDL?
type: item
description: Oh, STRTOK has been around for a while. Any illegal call to STRSPLIT (my common one, passing an array as a parameter) would crash it and expose a call to STRTOK. I think I even asked a question about it (long time ago), but I can't remember what kind of answer did I get. A real IDL hacker (like Craig) probably would know. Cheers, Pavel David Fanning wrote: > > David Fanning (davidf@dfanning.com) writes: > >> It is a moot point anyway, in this case, since the program >> uses some of the neat new SWITCH, BREAK, etc. stuff that >> comes in IDL 5.4, and will not compile in earlier versions. > > Interestingly, the FILE_WHICH program supplied in IDL 5.4 > calls a built-in, but undocumented, program STRTOK, which > appears to separate the path subdirectories based on > a delimiter supplied to the function. I'll leave it > to the expert sleuths in the group to tell us what it > *really* does. :-) > > Cheers, > > David > -- > David Fanning, Ph.D. > Fanning Software Consulting > Phone: 970-221-0438 E-Mail: davidf@dfanning.com > Coyote's Guide to IDL Programming: http://www.dfanning.com/ > Toll-Free IDL Book Orders: 1-888-461-0155
creator: Pavel A. Romashkin
date: 2001-01-05T16:57:11-00:00

Re: Which like command for IDL?
type: item
description: "Pavel A. Romashkin" wrote: > > Oh, STRTOK has been around for a while. Any illegal call to STRSPLIT (my > common one, passing an array as a parameter) would crash it and expose a > call to STRTOK. I think I even asked a question about it (long time > ago), but I can't remember what kind of answer did I get. A real IDL > hacker (like Craig) probably would know. > Cheers, > Pavel > > David Fanning wrote: >> >> David Fanning (davidf@dfanning.com) writes: >> >>> It is a moot point anyway, in this case, since the program >>> uses some of the neat new SWITCH, BREAK, etc. stuff that >>> comes in IDL 5.4, and will not compile in earlier versions. >> >> Interestingly, the FILE_WHICH program supplied in IDL 5.4 >> calls a built-in, but undocumented, program STRTOK, which >> appears to separate the path subdirectories based on >> a delimiter supplied to the function. I'll leave it >> to the expert sleuths in the group to tell us what it >> *really* does. :-) from /usr/local/rsi/idl/lib/strsplit.pro: ; NAME: ; STRSPLIT ; ; PURPOSE: ; Wrapper on the build in system routine STRTOK that implements exactly ; the same interface as STRTOK, but with the STRSPLIT name. ; ; The reason for doing this is so that if a user has their own ; STRSPLIT in their local user library, their version will superceed ; this one. RSI does not recommend this practice, but it is ; allowed for backwards compatability reasons. See the ; documentation for STRSPLIT in the IDL Reference manual ; for details on arguments, keywords, and results. ; The lesson for the day has been: built-ins cannot be overridden, unless RSI sets up a silly hack such as this to allow you to. JD
creator: John-David T. Smith
date: 2001-01-05T19:03:10-00:00

Re: Which like command for IDL?
type: item
description: Sorry for superseding my post, but I had left a rant in about routine_info/resolve_routine that I really didn't want to send, since I'd discovered some information about those two routines that made my rant a bit too splenetic, if you know what I mean. Anyway, I do have some problems with those two routines which I'll indicate below. davidf@dfanning.com (David Fanning) writes: > David Fanning (davidf@dfanning.com) writes: > >> It is a moot point anyway, in this case, since the program >> uses some of the neat new SWITCH, BREAK, etc. stuff that >> comes in IDL 5.4, and will not compile in earlier versions. > > Interestingly, the FILE_WHICH program supplied in IDL 5.4 > calls a built-in, but undocumented, program STRTOK, which > appears to separate the path subdirectories based on > a delimiter supplied to the function. I'll leave it > to the expert sleuths in the group to tell us what it > *really* does. :-) > <snip> If it's like the C function of the same name, it 'tokenizes' the string using any delimiter which appears in a particular set, which is input to the function. It's like repeated calls to strsplit with different delimiters. So, *IIRC* you could say 'stuff=strtok(path,':/\') and it would split the string up regardless of whether you were on a Windows of Unix machine. (I forget what the delimiter is for Vaxen) By the way, here's my entry into the (pre 5.4) field. It works by trying it as a system routine first, then it looks in the output from help,/source for an *exact* match of the input name (stopping at the first, see my below), then an object (if it has a :: in it) then procedure, a function and, if all these fail, it appends a '__define' on the input name and tries that, just in case someone just passed the name of the object it. It will even work if the object method is defined in it's own file, provided one follows the obj__method.pro naming convention. It has a *whole* slew (well, two actually) of GOTOs which I couldn't find a way to get rid of, mo…
creator: Vapuser
date: 2001-01-05T21:42:04-00:00

Re: Which like command for IDL?
type: item
description: JD Smith <jdsmith@astro.cornell.edu> writes: > I hate to be a one tune band, It's alright. It's a good note! [...] > > For one, it doesn't need IDL! It uses it's own notion of IDL builtins, > system library files (the ones in !DIR/lib), and the user catalog it > scanned. If IDL is running in the shell, it also queries it for all > routine info. Since I've scanned into my catalog almost everything on > !PATH (IDLWAVE makes it trivial) I just went and got the helpfile and then scanned my installation into my catalog. Man, you and Carsten are *wizards*. To paraphrase and line from a nutshell book: "Any sufficiently advanced technology is indistinquishable from well written emacs lisp package!" whd -- William Daffer: 818-354-0161: William.Daffer@jpl.nasa.gov
creator: Vapuser
date: 2001-01-05T22:29:14-00:00