How does IDL find functions? [message #44454] |
Fri, 17 June 2005 12:07  |
robertschaefer
Messages: 10 Registered: August 2004
|
Junior Member |
|
|
Hello IDL community,
I'm looking for a smart solution to find functions from my own lib
inside a self written function or procedure.
The idea is to get a tree of embedded self written functions.
My solution looks like this but I think there must be an easier way:
-generate a list of functions in user-lib
-Read the function where to search (openr)
-compare each line (string) with the list of lib functions
(how to extract function names egantly? -> strsplit with '=*(' :
definitely not)
-save coincide functions (strings) and go on searching into found
functions
Does anybody (I'm sure ;-) ) know how IDL find functions on compiling?
This may be exactly the right (fast) way...
Any ideas? ...Thanks for help...
Best regards
robert
|
|
|
|
|
Re: How does IDL find functions? [message #44546 is a reply to message #44454] |
Sun, 19 June 2005 23:13   |
Antonio Santiago
Messages: 201 Registered: February 2004
|
Senior Member |
|
|
robertschaefer@gmx.de wrote:
> Hello IDL community,
>
> I'm looking for a smart solution to find functions from my own lib
> inside a self written function or procedure.
> The idea is to get a tree of embedded self written functions.
>
That is: parse a file SOME_FILE.PRO and find if it contains any function
of your own library.
> My solution looks like this but I think there must be an easier way:
>
> -generate a list of functions in user-lib
1- You need to load into memory (array) a list of your functions name.
> -Read the function where to search (openr)
2- Read each file line.
> -compare each line (string) with the list of lib functions
> (how to extract function names egantly? -> strsplit with '=*(' :
> definitely not)
3- I think it will better with a STRMACTH or STREGEX.
This code can help you (extract from the old post
http://groups-beta.google.com/group/comp.lang.idl-pvwave/bro wse_thread/thread/bd3fc18ab72631ea/33089f602feb945c?hl=en#33 089f602feb945c):
Parse an entory file 'file' and found all functions or procedures that
starts with 'findstring'.
;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
> -save coincide functions (strings) and go on searching into found
> functions
4- I dont understand this part. Save the function that coincides with
your function names and then find recursively into functions with
different name??
>
> Does anybody (I'm sure ;-) ) know how IDL find functions on compiling?
> This may be exactly the right (fast) way...
>
> Any ideas? ...Thanks for help...
>
> Best regards
>
> robert
>
--
-----------------------------------------------------
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: How does IDL find functions? [message #44574 is a reply to message #44540] |
Thu, 23 June 2005 05:40  |
robertschaefer
Messages: 10 Registered: August 2004
|
Junior Member |
|
|
Thank you Benjamin, Reimar, Andrew and Antonio for your help, Antonios
example to use the "STREGEX" Function helped me to solve the problem
without compiling.
@ Mark: Maybe I have to excuse, that my english is not so good. With
"self written functions" i meant the functions belonging to my user
lib.
...but the previous authors understand my problem... so...?
|
|
|