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

Home » Public Forums » archive » Re: passing functions as arguments in IDL?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: passing functions as arguments in IDL? [message #18724] Tue, 01 February 2000 00:00
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Rick Baer (baer@hpl.hp.com) writes:

> Is there any way to pass functions as arguments in IDL? I would
> like to be able to do something like this:
>
> function f1, x
> return, x*x
> end
>
>
> pro tf1, func, arg
> return, func(arg)
> end
>
> IDL> print, tf1, f1, 4

You can do this:

function f1, x
return, x*x
end

function tf1, func, arg
IF Size(func, /Type) NE 7 THEN BEGIN
Print, 'String argument required'
RETURN, -1
ENDIF
retVal = Call_Function(func, arg)
return, retVal
end


IDL> print, tf1('f1', 4)

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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Update IDL 5.0 -> 5.3 error
Next Topic: IDL for DSLAM of Orckit

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

Current Time: Fri Oct 10 16:55:03 PDT 2025

Total time taken to generate the page: 1.36858 seconds