Re: functions as arguments ? [message #19041] |
Wed, 23 February 2000 00:00 |
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  |
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
|
|
|