|
|
|
Re: Locating IDL source code file [message #44414 is a reply to message #44411] |
Tue, 14 June 2005 06:14  |
Benjamin Hornberger
Messages: 258 Registered: March 2004
|
Senior Member |
|
|
Craig wrote:
> [copied over from comp.lang.idl - don't know how to properly cross-post
> it in retrospect using Google groups]
>
I believe comp.lang.idl is not about the Interactive Data Language, but
about some Interface Description Language.
>
> Hi all,
>
> I'm trying to write some code that will read information (like version
> numbers and dates) from the source files for procedures and functions
> that it uses. In Matlab I would use a command like
>
>
>>> which fred
>
>
> to return the full path to the source file "fred.m". How do I get the
> same result from IDL v6.1? I've tried something like
>
> IDL> ttt = file_which('fred.pro', /include_current_dir)
>
> but just got a null string returned. This might be because I'm using
> the IDLDE, so the routine isn't actually on the search path !PATH, even
> though it has been compiled OK when building the project.
>
> Once this problem is solved, I'll also need to determine the filename
> for the source file containing a definition of 'fred', because most of
> the routines in this project don't have their own 'fred.pro' source
> file.
>
> Any ideas?
> TIA,
> Craig
>
This might help:
http://www.dfanning.com/programs/programrootdir.pro
Still, file_which should also work if the source file is in the IDL
path. And I think you should always have your source files in the path.
Benjamin
|
|
|
Re: Locating IDL source code file [message #44416 is a reply to message #44414] |
Tue, 14 June 2005 05:41  |
Antonio Santiago
Messages: 201 Registered: February 2004
|
Senior Member |
|
|
Craig wrote:
> [copied over from comp.lang.idl - don't know how to properly cross-post
> it in retrospect using Google groups]
>
>
> Hi all,
>
> I'm trying to write some code that will read information (like version
> numbers and dates) from the source files for procedures and functions
> that it uses. In Matlab I would use a command like
>
>
>>> which fred
>
>
> to return the full path to the source file "fred.m". How do I get the
> same result from IDL v6.1? I've tried something like
>
> IDL> ttt = file_which('fred.pro', /include_current_dir)
>
> but just got a null string returned. This might be because I'm using
> the IDLDE, so the routine isn't actually on the search path !PATH, even
> though it has been compiled OK when building the project.
>
I almost nothing have used IDLDE (I use Emacs+IDLwave).
I testes your previous command in the IDL command line interpreter all
works fine. Perhaps you need to modify your IDLDE configuration path or
simething like this.
> Once this problem is solved, I'll also need to determine the filename
> for the source file containing a definition of 'fred', because most of
> the routines in this project don't have their own 'fred.pro' source
> file.
>
That is, yoru file.pro cotains procedured "fred" and "tom" ??
I think there is no function that does this for you, you need to open
and parse the file looking for a "PROCEDURE fred" string.
The next procedure opens a file and search for all procedure/funtions
that starts with the specified "findstring". If you put
findstring='fred' then also match names like 'frederic'.
;PRO parse, file, findstring
;; Open the file test.lis:
OPENR, 1, file
;; Define a string variable:
line = ''
;; Loop until EOF is found:
found = 0
line_number = 0
WHILE (~ EOF(1)) AND (NOT found) DO BEGIN
;; Read a line of text:
READF, 1, line
;; Check if match your procedure/function name
match = STREGEX(STRUPCASE(line), '(PROCEDURE|FUNCTION) ' + $
''+STRUPCASE(findstring), $
/BOOLEAN)
IF match THEN print, line_number, '-', line
line_number++
ENDWHILE
;; Close the file:
CLOSE, 1
END
--
-----------------------------------------------------
Antonio Santiago P�rez
( email: santiago<<at>>grahi.upc.edu )
( www: http://www.grahi.upc.edu/santiago )
( www: http://asantiago.blogsite.org )
-----------------------------------------------------
GRAHI - Grup de Recerca Aplicada en Hidrometeorologia
Universitat Polit�cnica de Catalunya
-----------------------------------------------------
|
|
|
Re: Locating IDL source code file [message #44417 is a reply to message #44416] |
Tue, 14 June 2005 05:25  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Craig wrote:
> [copied over from comp.lang.idl - don't know how to properly cross-post
> it in retrospect using Google groups]
>
>
> Hi all,
>
> I'm trying to write some code that will read information (like version
> numbers and dates) from the source files for procedures and functions
> that it uses. In Matlab I would use a command like
>
>
>>> which fred
>
>
> to return the full path to the source file "fred.m". How do I get the
> same result from IDL v6.1? I've tried something like
>
> IDL> ttt = file_which('fred.pro', /include_current_dir)
could be done in several ways
* if it is compiled, help,/source,out=out
* look for "current directory" or "get_profile_path" in the google forum or
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/get_profile_path_dbase.pro.html
* file_which if the routine is in !PATH
>
> but just got a null string returned. This might be because I'm using
> the IDLDE, so the routine isn't actually on the search path !PATH, even
> though it has been compiled OK when building the project.
you should think on using a startup script which organises the !path for
you. A startup file is used in idlde and idl the same way. just only an
environement variable IDL_STARTUP must be set to this file.
>
> Once this problem is solved, I'll also need to determine the filename
> for the source file containing a definition of 'fred', because most of
> the routines in this project don't have their own 'fred.pro' source
> file.
Then you want to separate between path file and extension.
you should have a look at:
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/file_path_name_ext_dbase.pro.html
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/icg-i/idl_icglib/idl_lib_intro. html
============================================================ =======
|
|
|