comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: calling a user-named procedure
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: calling a user-named procedure [message #7782 is a reply to message #7773] Wed, 15 January 1997 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
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
-----------------------------------------------------------
[Message index]
 
Read Message
Read Message
Previous Topic: MINOR CORRECTION
Next Topic: Re: File handeling architecture hints wanted

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 07:52:40 PDT 2025

Total time taken to generate the page: 0.96005 seconds