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

Home » Public Forums » archive » Re: functions as arguments ?
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: functions as arguments ? [message #19041] Wed, 23 February 2000 00:00
Pavel Romashkin is currently offline  Pavel Romashkin
Messages: 166
Registered: April 1999
Senior Member
I've looked at David's example. I just made up something similar. I
tried to keep the syntax closer to what Udo wanted. I see no obstacle
in IDL to call multiple embedded procedures or functions. However,
after several levels are embedded, it is really hard to understand what
the code is doing, in my opinion.

;******************
pro test

argument = 2.0
forward_function func1, func2
proc, func1(argument)
proc, func2(argument)

end

;******************
pro proc, input
; Perform action expected from PROC
print, input * 10
end

;******************
function func1, argument
return, argument + 1.
end

;******************
function func2, argument
return, argument + 2.
end

;******************


Udo Grabowski wrote:
>
> Hello,
>
> I'm looking for a way to do something like the Fortran construct
>
> program test
> call proc (func1)
> call proc (func2)
> end
> subroutine proc(func)
> call func
> end
>
Re: functions as arguments ? [message #19042 is a reply to message #19041] Wed, 23 February 2000 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Udo Grabowski (udo.grabowski@imk.fzk.de) writes:

> I'm looking for a way to do something like the Fortran construct
>
> program test
> call proc (func1)
> call proc (func2)
> end
> subroutine proc(func)
> call func
> end
>
> where func1,2 are given external functions defined somewhere.
> Functional arguments are seemingly not possible in IDL, but I found
> a preliminary and ugly solution with a wrapper class:

PRO JUNK
Print, 'In JUNK subroutine'
END

PRO JUNKER
Print, 'In JUNKER subroutine'
END

PRO TEST, func1, func2
Call_Procedure, func1
Call_Procedure, func2
END

IDL> TEST, 'JUNK', 'JUNKER'

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: Re: IDL Voodoo Experts Needed
Next Topic: functions as arguments ?

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

Current Time: Wed Oct 08 20:02:22 PDT 2025

Total time taken to generate the page: 0.00787 seconds