Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
eddie haskell wrote: > > hi, > i would like to be able to call a procedure whose name is given by the user during execution. example: > > pro stuff,filename > ... > call/execute, filename ;this is the line i cannot figure out > ... > > where filename is a string holding the name of a procedure (.pro file) input by the user e.g. from > > pro junk > ... > print,'input filename' > read,filename > stuff,filename ;call procedure stuff with filename as the argument > ... > > i have tried different syntaxes of execute and call_procedure but to no avail. > either i am just not phrasing things correctly, or i am on the wrong track. > does anyone know if this can be done, and if so, how? > > thanks, > eddie > ------------------------------------------------------------ ---------- > When you are a Bear of Very Little Brain, and you Think of Things, you > find sometimes that a Thing which seemed very Thingish inside you is > quite different when it gets out into the open and has other people > looking at it. > > - A.A. Milne, "The House At Pooh Corner" RESOLVE_ROUTINE The RESOLVE_ROUTINE procedure compiles user-written or library procedures or functions, given their names. Routines are compiled even if they are already defined. This procedure is similar to the .COMPILE executive command, but can be invoked within procedures and functions. Calling Sequence RESOLVE_ROUTINE, Name Arguments Name A scalar string or string array containing the name or names of the procedures to compile. If Name contains functions rather than procedures, set the IS_FUNCTION keyword. Keywords IS_FUNCTION Set this keyword to compile functions rather than procedures. See Also RESOLVE_ALL, .COMPILE in "Executive Commands" on page 2-10 of the IDL User's Guide. ============================================================ ========= resolve_routine,filename a=execute(filename) -- R.Bauer Institut fuer Stratosphaerische Chemie (ICG-1) Forschungszentrum Juelich email: R.Bauer@kfa-juelich.de
Eddie Haskell <haskell@ccpo.odu.edu> writes: > i would like to be able to call a procedure whose name is > given by the user during execution. > i have tried different syntaxes of execute and call_procedure but to no avail. > either i am just not phrasing things correctly, or i am on the wrong track. > does anyone know if this can be done, and if so, how? Here is an example that works. ******************************************************** PRO STUFF, filename, numLines ; Open the file, read and print the specified number of lines. OPENR, lun, filename, /GET_LUN fileInfo = STRARR(numLines) READF, lun, fileInfo FREE_LUN, lun PRINT,fileInfo END ;---------------------------------------------------------- PRO ASK_FOR_STUFF procedureName = "" READ, procedureName, PROMPT='Enter name of procedure to call: ' filename = "" READ, filename, PROMPT='Enter name of file to execute procedure on: ' CALL_PROCEDURE, procedureName, filename, 5 END ;---------------------------------------------------------- ******************************************************** I run it like this: IDL> ASK_FOR_STUFF Enter name of procedure to call: stuff Enter name of file to execute procedure on: junk.pro PRO JUNK, color IF MAX(number) GT 255 OR MIN(number) LT 0 THEN $ MESSAGE, 'Argument values must be in range of 0-255' base16 = [[1L, 16L], [256L, 4096L], [65536L, 1048576L]] I think from your example, you may have been confused about whether you wanted the name of the procedure as a string (which is what CALL_PROCEDURE wants) or the name of the file. I have shown both in this example so you can see the difference. Hope this sets you right. David ----------------------------------------------------------- David Fanning, Ph.D. Fanning Software Consulting 2642 Bradbury Court, Fort Collins, CO 80521 Phone: 970-221-0438 Fax: 970-221-4762 E-Mail: davidf@dfanning.com Coyote's Guide to IDL Programming: http://www.dfanning.com -----------------------------------------------------------